Skip to content

Commit c626b66

Browse files
prazgaitisclaude
andcommitted
add www variant to Better Auth trustedOrigins
SITE_URL is https://march.fit but users access https://www.march.fit, causing CSRF origin check to fail with 403. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent efdfea3 commit c626b66

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

packages/backend/auth.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ export const createAuth = (ctx: GenericCtx<DataModel>) => {
3131
"http://localhost:3000",
3232
"http://localhost:3001",
3333
process.env.SITE_URL || "",
34+
// Also trust www variant of the site URL
35+
...(process.env.SITE_URL
36+
? [process.env.SITE_URL.replace("://", "://www.")]
37+
: []),
3438
].filter(Boolean),
3539
emailAndPassword: {
3640
enabled: true,

0 commit comments

Comments
 (0)