handzon-core 0.12.1 → 0.12.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "handzon-core",
3
- "version": "0.12.1",
3
+ "version": "0.12.2",
4
4
  "description": "Core framework for Handzon — layouts, components, content + AI libs, and server runtime (handlers, DB, auth, migration runner) consumed by Handzon scaffolds.",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -24,6 +24,12 @@ interface AuthConfigOptions {
24
24
  * builds and for `pnpm build` on a fresh checkout without a database.
25
25
  */
26
26
  db: Parameters<typeof DrizzleAdapter>[0] | null;
27
+ /**
28
+ * Override auth-astro's route prefix when a fronting proxy rewrites
29
+ * paths before the request reaches the Handzon app. Defaults to
30
+ * Astro's configured `base` plus `/api/auth`.
31
+ */
32
+ authPrefix?: string;
27
33
  }
28
34
 
29
35
  /**
@@ -56,13 +62,14 @@ function resolveAuthUrl(): string | undefined {
56
62
  return undefined;
57
63
  }
58
64
 
59
- function resolveAuthPrefix(): string {
65
+ function resolveAuthPrefix(authPrefix?: string): string {
66
+ if (authPrefix) return authPrefix;
60
67
  const base = import.meta.env.BASE_URL;
61
68
  const normalizedBase = base === "/" ? "" : base.replace(/\/$/, "");
62
69
  return `${normalizedBase}/api/auth`;
63
70
  }
64
71
 
65
- export function createAuthConfig({ db }: AuthConfigOptions) {
72
+ export function createAuthConfig({ db, authPrefix }: AuthConfigOptions) {
66
73
  // Auth.js v5 reads `AUTH_URL` from process.env on each request, so
67
74
  // we resolve once and write it back. Idempotent: if AUTH_URL was
68
75
  // already a full URL, this is a no-op aside from the trailing-slash
@@ -72,18 +79,20 @@ export function createAuthConfig({ db }: AuthConfigOptions) {
72
79
  process.env.AUTH_URL = resolvedUrl;
73
80
  }
74
81
 
82
+ const prefix = resolveAuthPrefix(authPrefix);
83
+
75
84
  if (!db) {
76
85
  // No database → no adapter → no providers. auth-astro logs a warning
77
86
  // and any sign-in attempt fails gracefully instead of crashing the
78
87
  // build.
79
- return defineConfig({ providers: [] });
88
+ return defineConfig({ prefix, providers: [] });
80
89
  }
81
90
  return defineConfig({
82
91
  // auth-astro defaults to /api/auth, but Astro apps mounted with
83
92
  // `base` receive requests at /<base>/api/auth. Use the same base
84
93
  // that powers app links and API calls so the catch-all auth route
85
94
  // returns a Response instead of falling through with undefined.
86
- prefix: resolveAuthPrefix(),
95
+ prefix,
87
96
  adapter: DrizzleAdapter(db, {
88
97
  usersTable: users,
89
98
  accountsTable: accounts,