dvijaykrishnan commited on
Commit
eb36d07
·
1 Parent(s): 065e259

fix(auth): add production url to trustedOrigins and fix secure cookies

Browse files
Files changed (1) hide show
  1. src/lib/auth.ts +6 -2
src/lib/auth.ts CHANGED
@@ -40,9 +40,13 @@ export const auth = betterAuth({
40
  }
41
  },
42
  advanced: {
43
- useSecureCookies: false, // Ensure cookies work on HTTP localhost
44
  },
45
- trustedOrigins: ["http://localhost:3000", "http://127.0.0.1:3000"],
 
 
 
 
46
  secret: process.env.BETTER_AUTH_SECRET || (process.env.CI ? "dummy_secret_for_ci_build" : undefined),
47
  baseURL: process.env.BETTER_AUTH_URL || (process.env.CI ? "http://localhost:3000" : undefined),
48
  });
 
40
  }
41
  },
42
  advanced: {
43
+ useSecureCookies: process.env.NODE_ENV === "production", // Secure in prod, insecure in dev
44
  },
45
+ trustedOrigins: [
46
+ "http://localhost:3000",
47
+ "http://127.0.0.1:3000",
48
+ ...(process.env.BETTER_AUTH_URL ? [process.env.BETTER_AUTH_URL] : [])
49
+ ],
50
  secret: process.env.BETTER_AUTH_SECRET || (process.env.CI ? "dummy_secret_for_ci_build" : undefined),
51
  baseURL: process.env.BETTER_AUTH_URL || (process.env.CI ? "http://localhost:3000" : undefined),
52
  });