Closed thomizzi closed 2 years ago
facing a similar issue, any luck
I have the same problem
Same problem - is there already a solution?
Same problem.
I solved the problem. By checking header on laravel income requests I found those that were sent by server (in SSR mode) had wrong referer header. For me was ip address 192.168.0.53:3000
(and this is the ip that nuxt dev
serves your application).
I use domian (http://mydomain.test)
in my local dev envirement. So I forced nuxt auth user check
requests to use domain name as a referer
header and this fix the issue.
laravelSanctum: {
provider: "laravel/sanctum",
url: "http://api.mydomain.test",
endpoints: {
login: { url: "/v1/auth/login", method: "post" },
logout: { url: "/v1/auth/logout", method: "post" },
user: {
url: "/v1/auth-check",
method: "get",
withCredentials: true,
headers: {
Referer: "http://mydomain.test/" // <- here
}
}
}
}
I solved the problem. By checking header on laravel income requests I found those that were sent by server (in SSR mode) had wrong referer header. For me was ip address
192.168.0.53:3000
(and this is the ip thatnuxt dev
serves your application).I use domian
(http://mydomain.test)
in my local dev envirement. So I forced nuxt authuser check
requests to use domain name as areferer
header and this fix the issue.laravelSanctum: { provider: "laravel/sanctum", url: "http://api.mydomain.test", endpoints: { login: { url: "/v1/auth/login", method: "post" }, logout: { url: "/v1/auth/logout", method: "post" }, user: { url: "/v1/auth-check", method: "get", withCredentials: true, headers: { Referer: "http://mydomain.test/" // <- here } } } }
this is not working
See https://github.com/nuxt-community/auth-module/issues/1197 for SSR issues
I solved the problem. By checking header on laravel income requests I found those that were sent by server (in SSR mode) had wrong referer header. For me was ip address
192.168.0.53:3000
(and this is the ip thatnuxt dev
serves your application).I use domian
(http://mydomain.test)
in my local dev envirement. So I forced nuxt authuser check
requests to use domain name as areferer
header and this fix the issue.laravelSanctum: { provider: "laravel/sanctum", url: "http://api.mydomain.test", endpoints: { login: { url: "/v1/auth/login", method: "post" }, logout: { url: "/v1/auth/logout", method: "post" }, user: { url: "/v1/auth-check", method: "get", withCredentials: true, headers: { Referer: "http://mydomain.test/" // <- here } } } }
Not working
Version
module: 5.0.0-1624817847.21691f1 nuxt: 2.15.7
Nuxt configuration
mode:
Nuxt configuration
Reproduction
What is expected?
What is actually happening?
Additional information
First login
Login seems fine :white_check_mark: GET - 204 - /sanctum/csrf-cookie
:white_check_mark: POST - 201 - /api/v1/auth/login - Response with the token
{"token":"1|011qtLINVWL4RfoLkrYwG9GHGEW6gL20MwcMmfcX"}
:white_check_mark: GET - 200 - /api/v1/auth/user - Response with the user
{"id":1,"given_name":"Admin"}
:white_check_mark: Redirect to the dashboard (home: '/')
Browser refresh (F5)
:white_check_mark: GET - 200 - /api/v1/auth/user - Response with the user
{"id":1,"given_name":"Admin"}
🐛 Stay on /login
login.vue
I can bypass the problem by performing the following method in created(), but that's ugly. And it doesn't keep the browsing history.
Checklist
Laravel
routes/api.php
AuthController