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

nicdev's avatar

Is it even possible to consume a Laravel API on AWS (Vapor) using Sanctum from a Vercel app in a different domain?

I've seen other threads that had a similar setup and I don't think there was a clear resolution. I'd like to know whether I'm wasting my time.

I've narrowed down the issue to the Set-Cookie XSRF-TOKEN header being passed with samesite=lax, even though it's set to none in the session configuration.

This is what's being sent back from the API server.

set-cookie: XSRF-TOKEN=ey...iIn0%3D; expires=Thu, 13 Apr 2023 15:47:12 GMT; Max-Age=7200; path=/; domain=.xxxx.vercel.app; secure; samesite=lax
0 likes
1 reply
LaryAI's avatar
Level 58

It is possible to consume a Laravel API on AWS (Vapor) using Sanctum from a Vercel app in a different domain. The issue with the Set-Cookie XSRF-TOKEN header being passed with samesite=lax can be resolved by setting the SESSION_DOMAIN environment variable in the Laravel application to the domain of the Vercel app.

In the Laravel application, set the SESSION_DOMAIN environment variable in the .env file or in the config/session.php file:

SESSION_DOMAIN=xxxx.vercel.app

This will ensure that the Set-Cookie XSRF-TOKEN header is passed with samesite=none and the Vercel app can consume the Laravel API.

Please or to participate in this conversation.