File tree Expand file tree Collapse file tree
packages/nextjs/src/server Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ ' @clerk/nextjs ' : patch
3+ ---
4+
5+ Fix infinite handshake redirect loop when deploying Next.js apps with Clerk development instances to Netlify
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ import {
2222} from '@clerk/backend/internal' ;
2323import { clerkFrontendApiProxy , DEFAULT_PROXY_PATH , matchProxyPath } from '@clerk/backend/proxy' ;
2424import { parsePublishableKey } from '@clerk/shared/keys' ;
25+ import { handleNetlifyCacheInDevInstance } from '@clerk/shared/netlifyCacheHandler' ;
2526import { notFound as nextjsNotFound } from 'next/navigation' ;
2627import type { NextMiddleware , NextRequest } from 'next/server' ;
2728import { NextResponse } from 'next/server' ;
@@ -222,7 +223,13 @@ export const clerkMiddleware = ((...args: unknown[]): NextMiddleware | NextMiddl
222223
223224 const locationHeader = requestState . headers . get ( constants . Headers . Location ) ;
224225 if ( locationHeader ) {
225- const res = NextResponse . redirect ( locationHeader ) ;
226+ handleNetlifyCacheInDevInstance ( {
227+ locationHeader,
228+ requestStateHeaders : requestState . headers ,
229+ publishableKey : requestState . publishableKey ,
230+ } ) ;
231+
232+ const res = NextResponse . redirect ( requestState . headers . get ( constants . Headers . Location ) || locationHeader ) ;
226233 requestState . headers . forEach ( ( value , key ) => {
227234 if ( key === constants . Headers . Location ) {
228235 return ;
You can’t perform that action at this time.
0 commit comments