Server Proxy enabled but requests still show actual api endpoint #484
-
|
Hey @manchenkoff I’m trying to test the Nuxt SSR + nuxt-auth-sanctum serverProxy to proxy API requests through the frontend domain so Sanctum cookies and CSRF work as same-origin. According to the docs, enabling However, this does not appear to be working as expected. Am I missing something. export default defineNuxtConfig({
modules: [
'@nuxt/eslint',
'@nuxt/ui',
'@vueuse/nuxt',
'@nuxthub/core',
'nuxt-auth-sanctum'
],
ssr: true,
devtools: {
enabled: true
},
css: ['~/assets/css/main.css'],
routeRules: {
'/api/**': {
cors: true
}
},
compatibilityDate: '2024-07-11',
nitro: {
preset: 'cloudflare-pages'
},
eslint: {
config: {
stylistic: {
commaDangle: 'never',
braceStyle: '1tbs'
}
}
},
sanctum: {
baseUrl: '/api/sanctum',
serverProxy: {
enabled: true,
route: '/api/sanctum',
baseUrl: 'http://api.example.com'
},
redirect: {
keepRequestedRoute: true,
onAuthOnly: '/login',
onGuestOnly: '/'
},
globalMiddleware: {
enabled: true,
prepend: true,
allow404WithoutAuth: false
}
}
})Was I wrong to expect
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
|
Also, how'd we pass the |
Beta Was this translation helpful? Give feedback.
-
Hey @derrickobedgiu1 , this is correct. Here is the example of complete configuration to handle all requests internally: export default defineNuxtConfig({
modules: [
// ...
'nuxt-auth-sanctum',
],
ssr: true,
sanctum: {
baseUrl: '/laravel',
serverProxy: {
enabled: true,
baseUrl: 'http://localhost:80',
route: '/laravel',
},
},
})All requests will be sent to
Make sure you do not have any config cached and you do not override
I am almost sure that you do not need to set this manually since everything will be handled by Nuxt server.
I have not tested this infrastructure and as far as I know, it's in experimental mode for now. Please, make sure that it works locally first, then we'll be able to tell if it is related to the environment or there is a bug with a library. Most of the projects I use it for rely on Docker/VPS/pm2 node environment.
It's the same approach, Nuxt automatically converts all settings into format like |
Beta Was this translation helpful? Give feedback.
Hey @derrickobedgiu1 , this is correct. Here is the example of complete configuration to handle all requests internally:
All requests will be sent to
http://localhost:3000/laravel/*which will be redirected tohttp://localhost:80/*.