Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

wefwe's avatar
Level 1

how to set laravel sanctum csrf-cookie with nginx

Im setting vue3+vite+nginx+laravel sanctum, cannot establish sanctum csrf token verifying. sanctum requset [sanctum/csrf-cookie] doen't work with no headers. In frontend vue3 axios, "Set-Cookie" header must be returned by nginx server, But there is no cookie from nginx. Without nginx, everything is work well. vue3 axios send request [sanctum/csrf-cookie], and laravel sancum return "Set-Cookie" headers and check csrf-token so on.

Then, how to set laravel sanctum csrf-cookie with nginx?

0 likes
1 reply
wefwe's avatar
Level 1

I've got a answer by myself, there is huge update of over 10 version laravel framework, but some of my codes are in previous laravel 9 version. In common situation, combination of 9 and over 10 version codes works well. But some critical actions not work at all, like header response, etc. It is totally my fault cannot find real problem of tech stacks, but a little bit feeling unfair of framework.. So hard to know my mistake in the complex of these sources. Games end too already, but I hope may this answer helps anyone.

Please or to participate in this conversation.