Skip to content

Commit

Permalink
fix bug on auth trustHost
Browse files Browse the repository at this point in the history
environment AUTH_TRUST_HOST not being converted to boolean properly
  • Loading branch information
matyson committed Nov 6, 2024
1 parent 5c9fb4e commit fd3fe71
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion packages/auth/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ export const env = createEnv({
process.env.NODE_ENV === "production"
? z.string().min(1)
: z.string().min(1).optional(),
AUTH_TRUST_HOST: z.boolean().optional(),
AUTH_TRUST_HOST: z
.string()
// transform to boolean using preferred coercion logic
.transform((s) => s !== "false" && s !== "0")
.optional(),
NODE_ENV: z.enum(["development", "production"]).optional(),
BLUESKY_HTTPSERVER_URL: z.string().url(),
},
Expand Down
4 changes: 3 additions & 1 deletion packages/auth/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@ async function refreshBlueskyToken(refreshToken: string) {
return parsed;
}

console.log(env);

export const authConfig: NextAuthConfig = {
secret: env.AUTH_SECRET,
trustHost: !isSecureContext || env.AUTH_TRUST_HOST,
trustHost: env.AUTH_TRUST_HOST,
session: {
strategy: "jwt",
},
Expand Down

0 comments on commit fd3fe71

Please sign in to comment.