Firebase hosting does not support custom cookies

Firebase hosting does not support custom cookies

Firebase hosting with Nextjs : Session cookies

Firebase hosting is useful now just for simple websites but it is also possible and sometimes cheaper to use as frontend for Google Cloud Run. It is a very common usage pattern to simply map your firebase domain name to a another service running on Google cloud.

Sessions and session cookies

Firebase has not documented this but firebase will strip all cookies from the incoming request except on. "__session" cookie. This means if your backend is say Spring Boot which uses SESSION cookie by default or PHP or something else, you will not be able to maintain sessions when using firebase hosting.

The quick workaround for this is to either not use Firebase if you care about this a lot OR modify your service to only use __session cookie.

Why Firebase does this ?

Firebase does this to store static content more efficiently on CDN.

If you are using Firebase Hosting + Cloud Functions, __session is the only cookie you can store, by design. This is necessary for us to be able to efficiently cache content on the CDN -- we strip all cookies from the request other than __session. This should be documented but doesn't appear to be (oops!). We'll update documentation to reflect this limitation. source

Is this a serious drawback ?

When developing for web I do not like cases where we have to write our code to meet constrations that are arbitarily imposed by cloud providers. It makes your design weak in my opinion. It is a bit like designing frontends that only work for Internet Explorer 6 but nowhere else.