Search code examples
firebasecookiesjwtnuxt.jssubdomain

How to share JWT token between sub domain A and sub domain B both hosted on Firebase using Nuxt?


My main domain is igeddit.ca.

I have sub domain A: elearning.igeddit.ca and sub domain B: technical.igeddit.ca

The eLearning site is where users sign in and are verified and authorized by Firebase and receive their token. I save the token as a jwt cookie.

My understanding was that if I formatted the cookie in the following way, then I could share the cookie I created on sub domain A (elearning.iggedit.ca) with sub domain B (technical.igeddit.ca):

domain: '.igeddit.ca', path: "/", sameSite: 'strict', secure: true 

And, I thought it would work because I could view the cookie that I created on sub domain A when I inspected sub domain B:

cooking created on sub domain A elearning.igeddit.ca

viewing cookie on sub domain B technical.igeddit.ca

However, the token will not load on sub domain B. The following error is displayed:

404 error loading cookie

It seems I have everything right up until I load the cookie. Could the issue be that Google Firebase sites are prevented from sharing cookies. I read in a few places that Firebase only allows a specific session cookie that has to be written via Firebase functions...is this the case. Appreciate any insights.


Solution

  • After a lot of research, Google Firebase sites are prevented from sharing cookies with one another except for a session cookie: __session. I am posting a follow up question to this one because there seems to be a lot of confusion re. the __session cookie; probably because there are differences between Firebase v8 vs v9.