Laravel Sanctum -Vuejs身份验证问题,返回401(未经授权)
我的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 :
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了解决方案。因此,我在这里回答它,以便有类似问题的人受益。我正在使用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.