Closed Giuliopime closed 1 year ago
For all those who have the same issue, just create a plugin for axios and put
export default function ({ $axios }, inject) {
$axios.defaults.withCredentials = true
}
This allows the cookie to be sent and it's missing in the auth module
Another workaround is to set axios to use credentials in nuxt.config.js:
axios: {
credentials: true
}
Version
module: 5.13.6 nuxt: 2.15.7
Nuxt configuration
mode:
Nuxt configuration
~/schemes/customScheme.js
I use Ktor for my backend and when I login via the /login route I receive the following response so the cookie gets set correctly in the client browser.
The issue is that when I then try to fetch the user via the /user route the cookie doesn't get sent in the request and so I get a 401 back as the server doesn't get any session cookie so it threats me as unauthorized.
![Screenshot 2021-08-12 at 18 03 06](https://user-images.githubusercontent.com/60524738/129229812-86017ac3-bb0a-448d-a0eb-b125fd2cbb29.png)
Also I'm using the customScheme.js scheme because the normal fetchUser() method of the default local scheme just fails silently.
Questions
Checklist