Skip to content

Commit 0f21001

Browse files
committed
checkpoint
1 parent 481e88d commit 0f21001

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/auth/session.server.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,12 +244,13 @@ export function createOAuthStateCookie(
244244
state: string,
245245
isProduction: boolean,
246246
): string {
247-
// Use SameSite=Strict for OAuth state to prevent CSRF during OAuth flow
248-
return `oauth_state=${encodeURIComponent(state)}; HttpOnly; Path=/; Max-Age=${10 * 60}; SameSite=Strict${isProduction ? '; Secure' : ''}`
247+
// Use SameSite=Lax to allow the cookie to be sent on OAuth redirects back from providers
248+
// Strict would block the cookie since the redirect comes from an external domain (GitHub/Google)
249+
return `oauth_state=${encodeURIComponent(state)}; HttpOnly; Path=/; Max-Age=${10 * 60}; SameSite=Lax${isProduction ? '; Secure' : ''}`
249250
}
250251

251252
export function clearOAuthStateCookie(isProduction: boolean): string {
252-
return `oauth_state=; HttpOnly; Path=/; Max-Age=0; SameSite=Strict${isProduction ? '; Secure' : ''}`
253+
return `oauth_state=; HttpOnly; Path=/; Max-Age=0; SameSite=Lax${isProduction ? '; Secure' : ''}`
253254
}
254255

255256
export function getOAuthStateCookie(request: Request): string | null {

0 commit comments

Comments
 (0)