-
Notifications
You must be signed in to change notification settings - Fork 432
Description
Checklist
- The issue can be reproduced in the nextjs-auth0 sample app (or N/A).
- I have looked into the Readme, Examples, and FAQ and have not found a suitable solution or answer.
- I have looked into the API documentation and have not found a suitable solution or answer.
- I have searched the issues and have not found a suitable solution or answer.
- I have searched the Auth0 Community forums and have not found a suitable solution or answer.
- I agree to the terms within the Auth0 Code of Conduct.
Description
In the example for how to setup nextjs-auth0 with intl, there is a middleware file that show how to copy header values form Auth0 response to intl response. The code line that writes header values to intl response looks like this: intlRes.headers.set(key, value);
. If the header value exists, the previous value will be overwritten. The Auth0 response contains multiple set-cookie
headers. Since headers.set
is used in stead of headers.append
, only the last cookie is written to the response. Because of this error, the session is not updated correctly and it will expire before its absolute expiry time even though the user is actively using the application. Can we update the example so that it uses append
?
Also, I think it is a common use case to have other middleware that generates responses. Could the SDK be extended with a helper method for copying the header values?
Reproduction
.
Additional context
Example logging of headers that are copied from Auth0 response to intl response:
Copying cookie from auth response. "cache-control"="private, no-cache, no-sto..."
Copying cookie from auth response. "expires"="0..."
Copying cookie from auth response. "pragma"="no-cache..."
Copying cookie from auth response. "set-cookie"="__session__0=eyJlbmMiOiJB..."
Copying cookie from auth response. "set-cookie"="__session__1=rgPjj5rbkWdW..."
Copying cookie from auth response. "set-cookie"="__session=; Path=/; Max-A..."
Copying cookie from auth response. "set-cookie"="appSession=; Path=/; Max-..."
Copying cookie from auth response. "x-middleware-next"="1..."
Copying cookie from auth response. "x-middleware-set-cookie"="__session__0=eyJlbmMiOiJB..."
nextjs-auth0 version
4.10.0
Next.js version
15.5.3
Node.js version
22.18.0