-
Notifications
You must be signed in to change notification settings - Fork 910
Description
In my project, I am using nuxt/auth, nuxt/proxy and nuxt/axios. My Nuxt App lives on localhost:8080 while my API is located at localhost:5000. My API generates a session and sends a http-only cookie to the frontend.
I got everything working fine. Registering, logging in ... Only on reload the app kept on logging me out. When I checked the network requests, I figured that – on reload – the Nuxt server-side was trying to make a GET request to my API's users route that I specified in the auth config. But it prefixed it with '/api'! So the final url looked like this: /api/api/v1/me.
So I deleted the '/api' from my auth.endpoints.users config. And it worked. BUT: When I am calling this.$auth.fetchUser() on the client, the API call looks as follows: /v1/me 🤯.
Am I missing something here? Or is this a bug with the Auth module? Appreciate your help.
The are my auth, proxy and axios configs in nuxt.config.js:
auth: {
strategies: {
local: {
token: {
required: false,
type: false,
},
endpoints: {
login: { url: '/api/v1/auth/login', method: 'post' },
logout: { url: '/api/v1/auth/logout', method: 'post' },
user: { url: '/v1/me', method: 'get' }, // I am omitting the /api prefix here. And it's weird that I have to do this.
},
user: {
property: 'user',
autoFetch: false,
},
},
},
},
proxy: {
'/api/': {
target: process.env.API_URL,
pathRewrite: { '^/api/': '' },
},
},
axios: {
proxy: true,
credentials: true,
},