Can't seem to getCurrentUser() working on a page refresh SSR Nuxt #1490
-
Attempting to use middleware for route protection. Fails when a user refreshes the webpage definePageMeta({
name: 'myWebpage',
middleware: async function (to, from) {
const currentUser = await getCurrentUser()
if (currentUser && currentUser.uid === to.params.uid) {
return true
} else {
return navigateTo('/login')
}
},
}) Above code checks for the presence of a current user via However, the issue arises when an authenticated user refreshes the web page. Instead of maintaining their session on the myWebpage page, they are redirected to the login page ( I am uncertain how to get ...
vuefire: {
auth: {
enabled: true,
persistence: ['indexedDBLocal'],
},
config: {
apiKey: process.env.FIREBASE_API_KEY,
authDomain: process.env.FIREBASE_AUTH_DOMAIN,
projectId: process.env.FIREBASE_PROJECT_ID,
storageBucket: process.env.FIREBASE_STORAGE_BUCKET,
messagingSenderId: process.env.FIREBASE_MESSAGING_SENDER_ID,
appId: process.env.FIREBASE_APP_ID,
measurementId: process.env.FIREBASE_MEASUREMENT_ID,
},
emulators: true,
}, Recommendations on tackling this challenge would be very gratefully received. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
solved very simply vuefire: {
auth: {
enabled: true,
persistence: ['indexedDBLocal'],
sessionCookie: true,
},
... |
Beta Was this translation helpful? Give feedback.
solved very simply