Hi, I use Nextjs (React + Nodejs), firebase authentication, firestore, chakra UI to build an webapp.
Doubt
My doubt mainly focus on the authentication. I use firebase auth and it works very well. When a use requests login, if success, I will
(1) store the uid of the user into cookies in the backend (code shown below)
(2) set a global useStateuid = ${uid} in the frontend ( skip code for this part)
Hi, here is what I found recently. Let me separate into 2 time frame.
First Time Visit ( With Last time login cookie maybe several days ago)
When the first time I visited website, it had my last time cookie. So it redirected to the practice page. In this case, if I click logout, the cookie could be removed successfully.
It worked well in this case. However, it errors in the incoming case
Logout and Re-Login
Continue from the above scene. I logout successfully. Then, I re-login. It works. But when I click logout, it cannot logout.
Summary
First logout success, but then re-login and logout, the second logout failed. The cookie is still here with the re-login data.
Sometimes the error needs to be reproduced with one more round, i.e., another login-logout
This is beyond Netlify’s official scope of support - this is something relating to your code more than our service. Our team took one last look at it, and came up with the following. You’re of course welcome to ask further questions, but our staff may not respond since this is past what we intend to advise on (see Netlify Scope of Support for more details).
Since we see the /auth/logout URL called twice in the HAR file, but are seeing HTTP 304 responses, we don’t think the function was running when you gathered that HAR file. That response should never be cached and isn’t in our testing - perhaps you have or had a service worker or other interesting caching situation locally, not sure.
Today, we can see the function is SSR and is returning a cache-control: no-cache which should prevent this behavior. Is there any chance you changed anything about how this function runs since you gathered that data (perhaps it was not SSR before, or there used to be a different cache-control setting you were setting explicitly?) It’s a bit hard for us to see “past configuration” so we’ll just ask.