-
Notifications
You must be signed in to change notification settings - Fork 113
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
Setting session before login throws Error: Can’t set headers after they are sent
#89
Comments
I'm getting the exact same error when trying to use koa-session + Next.js with async/await functions. This is the code I have to write a UUID in the session:
I get the error even if I use it just as a middleware (without routing) unless I write the function as not async. |
@davegomez yes we are on nextJS also |
koa will send body when all middleware executed. but next.js is not follow this rule for now, it will send body before middleware executed, so when middleware's downstream try to set a header, it will throw this error. |
Any idea how to workaround this @dead-horse? @timneutkens from Next.js is already looking at the issue. |
there are lot's of middlewares will not work with next.js if it still use |
already fixed in new koa version, it will ignore set header if body already sent. |
@dead-horse which version? I am on |
I need to have
sessionId
even before user logs in, to tracks browsing session of user and tie him to it later when he logs in, so I did this:however if I do this I get (despite session id saving no problem)
Any idea what I am doing wrong?
The text was updated successfully, but these errors were encountered: