2

My app was fully hosted in cloud run and i was happy with that (except cloud run throws some statx container sandbox limitation errors).

Recently I moved the static files to firebase hosting and route api requests to cloud run (It seems awesome combo for me).

But some of my api routes (pointing to cloud run) uses cookies so I ran into another issue that firebase removes the cookies for cloud run routes.

Firebase hosting removes cookies. Is there any way to use my custom cookie for cloud run routes. I don't want cookies for static assets but need for cloud run requests.


Update:

I have read the another stackoverflow solution that firebase hosting strips all cookies other than a __session cookie, that's the only cookie it supports.

There is no way to use custom or multiple cookies in firebase hosting ‍♂️

In my use case the app authentication uses a cookie variable and after authentication session (session also set cookies, so multiple cookies are there) will set.

What I have tried: In order to work session cookies, I have changed session cookie name to __session so both uses __session.

The problem is session no longer works. Because when I check request headers, multiple __session cookies set like the following,

Cookie: __session=auth_1234 __session=s%jashd3yq4kqj-sd43.jasyd7346%asdkjh4%asdkhk3j4h

Is there any way to overwrite previous __session cookie?

Because session cookie is set automatically by express session, right?

CaptainZero
  • 1,431
  • 1
  • 19
  • 38
  • The duplicate link is for Cloud Functions, but the same logic would apply for Cloud Run. – Doug Stevenson Aug 11 '19 at 16:26
  • @DougStevenson I already read that but I would like to know there is an option to store custom cookies other than __session, or how can I store multiple cookies? Thanks in advance – CaptainZero Aug 11 '19 at 17:01
  • 1
    The answer there clearly says there is no alternative - "we strip all cookies from the request other than __session". – Doug Stevenson Aug 11 '19 at 17:23
  • I have edited my question, that's the use case of my app. Firebase hosting may not be suitable for my use case. – CaptainZero Aug 15 '19 at 05:23
  • The question has already been marked as a duplicate, which means it can't accept new answers. If you have a new question, you should post it separately. – Doug Stevenson Aug 15 '19 at 13:25
  • Oh, sorry I was not aware of that. Thanks for the info. – CaptainZero Aug 15 '19 at 14:32
  • Wow. I just spent 5 days reading every single line (and rewriting it in my own notes) of the Firebase docs only to come across this total deal-breaker tucked away that's not even highlighted as important! https://firebase.google.com/docs/hosting/manage-cache#using_cookies - this is why I obsess over reading cloud services docs before I write any code. – Luke Puplett Nov 26 '21 at 11:45

0 Answers0