尽管有适当的X-XSRF标头,但仍会收到Laravel CSRF令牌不匹配错误

发布于 2025-02-05 19:20:03 字数 554 浏览 2 评论 0原文

与Laravel的后端一起使用棱角侧的前端,我似乎无法与Sanctum一起越过CSRF步骤。

很奇怪的是,我正在击中 /sanctum /csrf-cookie页面,然后将xsrf-token cookie返回(图像1),当我在Laravel击中我的 /auth路线时适当设置(图2),但它仍然给我带来CSRF代币不匹配错误。

”

预先感谢!

Working with an Angular front end with a Laravel back end, and I can't seem to get past the CSRF step with Sanctum.

The weird thing is that I'm hitting the /sanctum/csrf-cookie page and getting the XSRF-Token cookie back (image 1), and when I hit my /auth route in Laravel the X-XSRF-TOKEN header seems to be set appropriately (image 2), but it's still giving me the CSRF token mismatch error.

XSRF-Token cookie returned

X-XSRF-Token header sent

Thanks in advance!

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

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

发布评论

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

评论(1

御弟哥哥 2025-02-12 19:20:03

看来我只需要从我的kernel.php中的API中间件组中删除确保FrontendRequestSarestateFul。

It looks like I just needed to uncomment the EnsureFrontendRequestsAreStateful line from the api middleware group in my Kernel.php.

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