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
Hey,
I need my project to run on IE11. I was able to run next-auth on IE11 with next-transpile-modules (code in snippet).
But there's one more problem: every subsequent request to /session endpoint (caused by useSession hook) returns cached version of first request.
Why it's problematic - for example: I'm visiting my website with active session, request is sent to /session and response (with active session with user object) is cached. Then I log out, page refreshes but I'm still getting cached active session with user object - incorrect.
In other browsers it works normally - the request is not cached.
Only way to solve this is to clear cache via IE11 dev tools, or to shut down browser and open it again.
Setting clientMaxAge option to 1 didn't help too.
I solved it manually by changing this in my node_modules/next-auth
From what I've read pragma: no cache header is like cache-control: no-cache but for older browsers. I tested cache-control too but it didn't work. Req seemed to be falsy in my case, so I added it to "else" part of above ternary operator.
So it solves the problem for me temporarily, but I don't know if thats solution for you and how it fits in the rest of Next Auth.
I'd be grateful if someone had a look at this ;)
Is this a bug in your own project?
No
How to reproduce ☕️
Here's all you need to change in next starter template (I cut only needed parts from my bigger project, but tested it and it reproduces error well). CodeSandbox doesn't work in IE11, sorry :( Just open app, refresh the page and inspect /session response in IE11 devtools, it should say its cached.
Description 🐜
Hey,
I need my project to run on IE11. I was able to run next-auth on IE11 with next-transpile-modules (code in snippet).
But there's one more problem: every subsequent request to /session endpoint (caused by useSession hook) returns cached version of first request.
Why it's problematic - for example: I'm visiting my website with active session, request is sent to /session and response (with active session with user object) is cached. Then I log out, page refreshes but I'm still getting cached active session with user object - incorrect.
In other browsers it works normally - the request is not cached.
Only way to solve this is to clear cache via IE11 dev tools, or to shut down browser and open it again.
Setting clientMaxAge option to 1 didn't help too.
I solved it manually by changing this in my node_modules/next-auth
next-auth/src/client/index.js
Line 320 in f546e55
to
const options = req ? { headers: { cookie: req.headers.cookie } } : { headers: { Pragma: 'no-cache'}}
From what I've read pragma: no cache header is like cache-control: no-cache but for older browsers. I tested cache-control too but it didn't work. Req seemed to be falsy in my case, so I added it to "else" part of above ternary operator.
So it solves the problem for me temporarily, but I don't know if thats solution for you and how it fits in the rest of Next Auth.
I'd be grateful if someone had a look at this ;)
Is this a bug in your own project?
No
How to reproduce ☕️
Here's all you need to change in next starter template (I cut only needed parts from my bigger project, but tested it and it reproduces error well). CodeSandbox doesn't work in IE11, sorry :( Just open app, refresh the page and inspect /session response in IE11 devtools, it should say its cached.
/next.config.js
/pages/api/[...nextauth.js]
/pages/_app.js
/pages/index.js
Screenshots / Logs 📽
Environment 🖥
IE11 / Windows 10
Contributing 🙌🏽
Yes, I am willing to help solve this bug in a PR
The text was updated successfully, but these errors were encountered: