Skip to content

Commit 184e184

Browse files
brkalowclaude
andcommitted
fix(backend): use redirect:'manual' in frontend API proxy fetch
fetch() defaults to redirect:'follow', which causes it to chase same-origin redirects server-side. When FAPI returns a 302 back to the app origin (e.g. after OAuth callback), the proxy's fetch follows the redirect internally — hitting the app without auth cookies — instead of passing the 302 to the browser. This breaks OAuth flows by rendering the sign-in page at the callback URL. Adding redirect:'manual' ensures the 302 is returned to the browser as-is, letting the browser handle the navigation with proper cookies. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 857823e commit 184e184

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

packages/backend/src/proxy.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,11 @@ export async function clerkFrontendApiProxy(request: Request, options?: Frontend
272272
const fetchOptions: RequestInit = {
273273
method: request.method,
274274
headers,
275+
// Return redirects as-is instead of following them server-side.
276+
// Without this, fetch() follows same-origin redirects internally,
277+
// which bypasses the browser and breaks flows like OAuth callbacks
278+
// where FAPI redirects back to the app origin.
279+
redirect: 'manual',
275280
// @ts-expect-error - duplex is required for streaming bodies but not in all TS definitions
276281
duplex: hasBody ? 'half' : undefined,
277282
};

0 commit comments

Comments
 (0)