You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// If intlRes is already redirecting or returning an error,
// do not copy 'x-middleware-next' from authResponse.
// This allows intlRes's redirect/error to take effect.
continue;
}
}
// For all other headers, or if 'x-middleware-next' can be safely copied,
// set them on intlRes. This ensures session cookies from authResponse are preserved.
intlRes.headers.set(key,value);
}
After cookie chunking caused cookies to be split, we noticed that the authentication state was not retained.
Upon closer inspection, we found that some of the chunked session cookies were not being stored as cookies.
I noticed that the authResponse in example contains multiple set-cookie headers, so I solved this by using headers.append instead of headers.set.
// add any headers from the auth middleware to the responsefor(const[key,value]ofauthResponse.headers){// Only copy 'x-middleware-next' if the custom middleware response intends to proceed.if(key.toLowerCase()==='x-middleware-next'&&!shouldProceed){continue;// Skip copying this header if we are blocking/redirecting}someOtherResponse.headers.append(key,value)}
Has anyone encountered a similar event or tried a better solution?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Prior to v4.3.0, we implemented Combining middleware by referring to the following documents and examples.
https://github.com/auth0/nextjs-auth0/blob/main/EXAMPLES.md#combining-middleware
nextjs-auth0/examples/with-next-intl/middleware.ts
Lines 20 to 39 in bf35b96
After cookie chunking caused cookies to be split, we noticed that the authentication state was not retained.
Upon closer inspection, we found that some of the chunked session cookies were not being stored as cookies.
I noticed that the authResponse in example contains multiple
set-cookie
headers, so I solved this by usingheaders.append
instead ofheaders.set
.Has anyone encountered a similar event or tried a better solution?
Beta Was this translation helpful? Give feedback.
All reactions