-
-
Notifications
You must be signed in to change notification settings - Fork 247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
await session.save() fails to set cookie if cookies.set() is used after #684
Comments
Same here, cookie won't update on |
I can confirm this issue. We are chaining middleware functions together. Simplified examples: function setCookieMiddleware(req, res, ctx) {
res.cookies.set('foo', 'bar', { httpOnly: false })
return res
}
async function saveSessionMiddleware(req, res, ctx) {
ctx.session.foo = 'bar'
await ctx.session.save()
return response
}
// DOES NOT WORK: session cookie is not set in response headers, only foo cookie is present
const middlewares = [
saveSessionMiddleware,
setCookieMiddleware,
]
// DOES WORK: both session cookie and foo cookie Set Cookie header present in response headers
const middlewares = [
setCookieMiddleware,
saveSessionMiddleware,
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I tested this in middleware and any invocation of response.cookies.set() on a NextResponse after saving the session with await session.save() will not set the new session as a cookie.
The text was updated successfully, but these errors were encountered: