-
-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Question] 401 error get user #191
Comments
Hey @mohamad4j to properly use token mode, you should fix your export default defineNuxtConfig({
compatibilityDate: '2024-04-03',
devtools: { enabled: true },
ssr: false,
modules: ['nuxt-auth-sanctum'],
sanctum: {
baseUrl: 'http://localhost:8000/api', // Laravel API
mode: "token",
redirectIfAuthenticated: false,
redirectIfUnauthenticated: false,
endpoints: {
login: '/auth/login',
user: '/auth/user',
logout: "/auth/logout",
},
redirect: {
onLogin: false,
onAuthOnly: "/login",
keepRequestedRoute: true,
},
},
}) and make sure that your Nuxt application URL is not included in the stateful domain list. Please, also change |
@mohamad4j I see, looks like you are using an old version, please upgrade to 0.4.17 and try again |
I meant to send the logs with a new version |
@mohamad4j |
@mohamad4j yes, for cookie you should use different middleware on Laravel side (include domain into stateful list) and make minor changes in module config, check details here - https://manchenkoff.gitbook.io/nuxt-auth-sanctum/authentication/spa-cookie |
I'm closing this for now, feel free to create a new one if new issue appears. |
Describe the bug
I can login successfully but it cannot get user. always I get 401. I think the token isn't set in header and I don't know why?
I checked all config for both laravel and nuxt
Laravel sanctum config:
corse.php
The text was updated successfully, but these errors were encountered: