-
I'm attempting to sign in with: this.$auth.loginWith('cookie', { ... }) The server returns the cookie set by the backend, but the browser seems to ignore it. The next request to get the current user fails with a 401. However, the cookie is properly set if I call the login endpoint directly using await $fetch("....", {
method: "POST",
body: {
...
},
}); Is something else required to make this work? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I found the solution. The endpoints configured in This can be fixed by adding a endpoints: {
login: {
url: '/api/login',
method: 'post',
credentials: 'same-origin',
},
user: {
url: '/api/user/',
method: 'get',
credentials: 'same-origin',
},
}, See here for more information on this setting. |
Beta Was this translation helpful? Give feedback.
I found the solution.
The endpoints configured in
nuxt.config.ts
, by default, havecredentials: 'omit'
. This causes the fetch api to not send nor accept any cookies.This can be fixed by adding a
credentials
key to the configuration:See here for more information on this setting.