N
Nuxtβ€’8mo ago
Jonas Reif

Preventing ISR Caching for Authenticated Users on Vercel with Nuxt

We're using Nuxt's hybrid rendering for our app, specifying different ISR settings for public pages and our login area to ensure up-to-date data. Here's our setup:
'/**': { isr: 3600 }, //
'/de/app/*': { isr: false }
'/**': { isr: 3600 }, //
'/de/app/*': { isr: false }
To redirect authenticated users from public pages to the login area, we use a global middleware:
export default defineNuxtRouteMiddleware(async (to, from) => {
const authStore = useAuthStore() // authstore is a pinia store which saves auth data into cookies

if (authStore.userIsAuthenticated) {
return navigateTo(useNuxtApp().$localePath('/app))
}
})
export default defineNuxtRouteMiddleware(async (to, from) => {
const authStore = useAuthStore() // authstore is a pinia store which saves auth data into cookies

if (authStore.userIsAuthenticated) {
return navigateTo(useNuxtApp().$localePath('/app))
}
})
` When an authenticated user accesses a public page exactly when the 3600-second cache expires, they are correctly redirected as intended. However, Vercel caches this redirect action, causing even unauthenticated users to be redirected. Question How can we prevent or bypass ISR caching for authenticated users, or avoid caching these redirects on Vercel? Is there a specific configuration or approach that could help in this scenario? Is there also a way to bypass all ISR caching in some scenarios globally (e.g. when user is authenticated) Thanks for your help! πŸ™‚
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server