Closed snapxtp closed 4 months ago
For those who use Firebase hosting and firefunction, the solution is to write a cookie with the name "__session" and read it as mentioned below. !!!!
It might be good to include it in the Nuxt3 Firebase deployment documentation.
https://www.reddit.com/r/Nuxt/comments/1aw50al/accessing_cookies_in_prod/
Would you see if you can reproduce this in pure Nitro (reproduction sandbox), and if so, raise there? 🙏
For those who use Firebase hosting and firefunction, the solution is to write a cookie with the name "__session" and read it as mentioned below. !!!!
It might be good to include it in the Nuxt3 Firebase deployment documentation.
https://www.reddit.com/r/Nuxt/comments/1aw50al/accessing_cookies_in_prod/
I've spent 2 days doubting the whole implementation of the cookies, and trying absurd things to solve this same issue. I've just switched the cookie name to __session
and solved the issue. Thank you.
PS: They have it in the firebase docs, but agree 100% that we should have this in the Nuxt3 firebase deployment docs. https://firebase.google.com/docs/hosting/manage-cache#using_cookies
Gosh, I spent over 2 hours with this problem, thankfully I found this thread, otherwise it would have been days. This should definitely be part of the Firebase deployment instructions
PR welcome for the docs 🙏🏻
Environment
{ "name": "nuxt-app", "private": true, "type": "module", "scripts": { "build": "nuxt build --dotenv .env.prod", "dev": "nuxi dev --dotenv .env.dev", "generate": "nuxt generate", "preview": "nuxt preview", "postinstall": "nuxt prepare", "build:firebase": "npm run build -- --preset=firebase" }, "dependencies": { "@mdi/font": "^7.4.47", "@pinia/nuxt": "^0.5.1", "material-design-icons-iconfont": "^6.7.0", "pinia": "^2.1.7", "save": "^2.9.0", "vue": "^3.4.19", "vue-router": "^4.2.5", "vuetify": "^3.5.1" }, "devDependencies": { "@sidebase/nuxt-session": "^0.2.8", "firebase": "^10.8.0", "firebase-admin": "^12.0.0", "firebase-functions": "^4.7.0", "nuxt": "^3.10.3", "nuxt-font-loader": "^2.3.5", "sass": "^1.70.0", "sass-loader": "^14.0.0", "vite-plugin-vuetify": "^2.0.1" } }
Reproduction
The login process application with server side cookie control using firebase admin sdk, which works fine in local environment, does not work after compilation and publishing on firebase. What I saw in the logs is that cookies cannot be read on the server side with useCookie.
Values cannot be read when the page is refreshed.
COOKIE always returns null. Also, no cookie is added in the header information in the queries made.
`export default defineNuxtRouteMiddleware(async (to, from) => {
}) `
Describe the bug
The login process application with server side cookie control using firebase admin sdk, which works fine in local environment, does not work after compilation and publishing on firebase. What I saw in the logs is that cookies cannot be read on the server side with useCookie.
Values cannot be read when the page is refreshed.
COOKIE always returns null. Also, no cookie is added in the header information in the queries made.
Additional context
The login process application with server side cookie control using firebase admin sdk, which works fine in local environment, does not work after compilation and publishing on firebase. What I saw in the logs is that cookies cannot be read on the server side with useCookie.
Values cannot be read when the page is refreshed.
COOKIE always returns null. Also, no cookie is added in the header information in the queries made.
Logs
No response