Persistence Auth with SSR

  • Hi Guys,

    Maybe my question it’s very obvious, but I am having a problem to keep the auth in my SSR app.

    I am using Firebase Auth, I have set up the service for Server and Client, the problem is with the I am enabled the Auth because the storage and Cookies are cleaners.

    Does anyone know how I should handle this? Should I keep the Token on the client and then send it to Server? What do you advise me to solve this case with firebase Auth?

  • Regarding the firebase, i really don’t know, since them is completely out of of knowledge.

    But u can use the QCookies to share data between the client and server.

    However, you aren’t able to read cookies from another domain, so you can’t read cookies of a third party api, like firebase.

    If u wanna to share a vuex module, you would use vuex-persistedstate, here a example.:

    import { Cookies } from 'quasar'
    import createPersistedState from 'vuex-persistedstate'
    export default function ({ store, ssrContext }) {
      const cookies = process.env.SERVER
        ? Cookies.parseSSR(ssrContext)
        : Cookies
        paths: ['shared'],
        filter ({ type }) {
          return type.startsWith('shared')
        storage: {
          getItem (key) {
            return JSON.stringify(cookies.get(key))
          setItem (key, value) {
            cookies.set(key, value)
          removeItem (key) {

    But remember, cookies are very limited, so be very selective about what you’ll persist.

  • Hi @Tobias-Mesquita ,

    Thanks for reply.

    Yes, I was using the same structure… I had to find another solution, in this case, I am using the SW to have control of the firebase Auth in the Client-Side ( I can’t say that it was the most elegant solution because I still have some doubts about safety, but at least I could get unstuck in which he was.

Log in to reply