Default baseUrl is used when logging in after navigating from pre-rendered page #474
-
|
I have an application that should use a specific backend URL set using Reloading the page would sometimes fix the issue. After looking into this a bit more I noted that if I try to log in after I go to my login page from some other page, that is pre-rendered, then this issue would occur. In my case, the index page is pre-redered, but the login page is not. So:
would make the app use the default Is this the intended behavior? The only solution I could come up with is to set My Nuxt config: export default defineNuxtConfig({
compatibilityDate: '2025-07-15',
devtools: { enabled: true },
modules: [
'@nuxt/image',
'vuetify-nuxt-module', // Vuetify
'nuxt-auth-sanctum' // Laravel Sanctum auth
],
nitro: {
prerender: {
routes: ["/", /* ... */],
},
},
sanctum: {
baseUrl: process.env.NO_DEFAULT_SANCTUM_URL === 'true' ? undefined : 'http://localhost:8000',
redirect: {
onLogin: '/dashboard',
onLogout: "/",
onAuthOnly: '/login',
keepRequestedRoute: false,
onGuestOnly: false,
},
redirectIfAuthenticated: true
},
typescript: {
strict: true,
typeCheck: true,
}
}); |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Hey @br0kenpixel, this is out of the package control since Nuxt takes care of propagating env/config by itself. My guess is that Nuxt compiles this config for prerendered pages, so it does not get updated when you navigate to another route. I would recommend doing the opposite, define |
Beta Was this translation helpful? Give feedback.
Hey @br0kenpixel, this is out of the package control since Nuxt takes care of propagating env/config by itself. My guess is that Nuxt compiles this config for prerendered pages, so it does not get updated when you navigate to another route.
I would recommend doing the opposite, define
NUXT_PUBLIC_SANCTUM_BASE_URLfor local development and have production config innuxt.config.ts, it should help.