nuxt-community / firebase-module

🔥 Easily integrate Firebase into your Nuxt project. 🔥
https://firebase.nuxtjs.org
MIT License
641 stars 99 forks source link

Missing res.locals on hard refresh (SSR auth) #530

Closed GanchoDanailov closed 3 years ago

GanchoDanailov commented 3 years ago

Version

@nuxtjs/firebase: 7.5.0 @nuxtjs/pwa: 3.3.5 firebase: 8.6.1 nuxt: 2.15.3

Reproduction Link

https://codesandbox.io/s/test-758x2?file=/store/index.js:584-594 https://758x2.sse.codesandbox.io/

Steps to reproduce

login -> hard refresh the page (Chrome mac - Cmd Shift R) -> missing res.locals on server. (On soft refresh res.locals are ok)

What is Expected?

On hard refresh - Expecting res.locals on the server

What is actually happening?

missing res.locals on the server on hard refresh

soft-refresh hard-refresh
GanchoDanailov commented 3 years ago

any update on this? Could you please confirm its known issue

lupas commented 3 years ago

Hey @GanchoDanailov

This is expected.

When you shift-reload, the reloaded page will not be controlled by a service worker. This is part of the service worker specification.

So you won't be able to have server side authentification when a user uses shift-reload -> because no service worker can get the auth credentials and send them to the server before pageload.

If you have onAuthStateChanged configured however, the user gets logged in right afterwards in such a case.

Like you can see here: https://nuxt-fire-demo.herokuapp.com/