admin管理员组文章数量:1399251
I have a confusing situation with NextJS and session cookies and middleware, the flows are:
- New user hits site -> middleware creates a new anon session token and sets the set cookie header in the response -> page is rendered and looks for the cookie (and usually finds it...! which is not expected?)
- Existing user hits site -> middleware checks session token validity and optionally refreshes it if possible -> page is rendered
Now I am getting a load of weird errors here that I am finding really hard to reproduce:
- Ocasionally I am seeing an error in the logs that a session token could not be found by the page and so it fails to render (seems to be limited to being hit by bots but why!?!?). I have tested hitting the site directly with curl and it seems to work fine.
- Users are sporadically getting 401 errors, when I delved deeper the session token was either missing or had expired, perhaps corrupted tokens.
If anyone has any insights into the expected flow of data in the request and response between NextJS middleware and pages I would love to know what is actually expected to happen here.
本文标签: authenticationNextJS midleware flow of cookiesheadersStack Overflow
版权声明:本文标题:authentication - NextJS midleware flow of cookiesheaders - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744209650a2595359.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论