Open AndreasJacobsen opened 3 years ago
@AndreasJacobsen any luck figuring out a more secure solution?
The issue comes from Firebase deleting cookies when using Firebase Functions or Cloud Run, as it only allows for using a special-named cookie called __session
, try updating the name of the cookie from token
to __session
and it might do the trick.
This guide seems to no longer work with nextjs 10+.
Tested using code with my own specifications and copy paste from this repo. I also tested using both nookies and js-cookies
What happens: Token gets set correctly on login page, I can see the token in the applications panel of my chrome devtools. Whenever the token is used in SSR the token is shown as invalid by firebase and deleted from the front end cookie storage.
When trying to use this token on a SSR page the token dissapears, firebase gives an error stating
My auth.tsx (at this point copy paste from this repo, tried replacing nookies with js-cookies but got the same issue)
Relevant versions:
What have I tried? Shifting from nookies to js-cookies Using the encode option with nookies
Edit: Tested with NextJS 11, same issue. It seems like the issue happens in auth.tsx when token is being unset if no user is present. The token gets unset when ran un an SSR page.
by commenting out the destruction of the cookie things begin working. But this seems to be like a very sub-optimal and possible insecure solution.