Laravel Sanctum -Vuejs身份验证问题,返回401(未经授权)

发布于 2025-01-31 03:53:15 字数 750 浏览 0 评论 0原文

我的Laravel Sanctum -Vuejs身份验证系统效果很好。但是它在实时服务器中不起作用。我已经尝试了各种env配置 - 但是什么都没发生... 我的域具有ssl btw

我的env:

APP_NAME=Laravel
APP_ENV=Production
APP_DEBUG=true
APP_URL=https: // domain.com /

LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=*****
DB_USERNAME=*****
DB_PASSWORD=*****

BROADCAST_DRIVER=log
CACHE_DRIVER=file
FILESYSTEM_DRIVER=local
QUEUE_CONNECTION=sync
SESSION_DRIVER=cookie
SESSION_LIFETIME=120
SESSION_DOMAIN=domain.com
SESSION_SECURE_COOKIE=false
SANCTUM_STATEFUL_DOMAINS=domain.com

我正在共享请求标题:

My laravel sanctum - vuejs authentication system works fine ibn localhost. But It does not work in live server. I have tried with various env configurations - but nothing is happening ... My domain has SSL btw

My ENV :

APP_NAME=Laravel
APP_ENV=Production
APP_DEBUG=true
APP_URL=https: // domain.com /

LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=*****
DB_USERNAME=*****
DB_PASSWORD=*****

BROADCAST_DRIVER=log
CACHE_DRIVER=file
FILESYSTEM_DRIVER=local
QUEUE_CONNECTION=sync
SESSION_DRIVER=cookie
SESSION_LIFETIME=120
SESSION_DOMAIN=domain.com
SESSION_SECURE_COOKIE=false
SANCTUM_STATEFUL_DOMAINS=domain.com

I am sharing the request header :

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

羁绊已千年 2025-02-07 03:53:15

我找到了解决方案。因此,我在这里回答它,以便有类似问题的人受益。我正在使用Auth Munderware进行API保护,但在控制器中实现了手动身份验证,而不是默认身份验证。这会导致问题,因为前端无法与cookie“ auth”产生相匹配。

I found the solution. So I am answering it here so that people with similar problems get benefited. I was using Auth middleware for API protection but implemented manual authentication in the controller instead of default Auth. That causes the problem since the frontend could not match the cookie "Auth" produces.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文