CORS in Laravel Sanctum SPA Authentication

Laravel Sanctum SPA auth looks simple on paper: frontend hits /sanctum/csrf-cookie, then logs in, then sends session cookies with future API requests. The part that trips people up is CORS. Not because CORS is complicated in theory, but because Sanctum relies on cookies + CSRF + stateful requests, and browsers get very picky when credentials are involved. If your React, Vue, or Nuxt frontend lives on http://localhost:5173 and your Laravel API lives on http://localhost:8000, you’re in CORS territory immediately. ...

October 8, 2026 · 6 min · headertest.com

CORS vs CSRF: What’s the Difference?

CORS and CSRF get lumped together way too often. I’ve seen teams say “we enabled CORS, so we’re protected from CSRF now” and then act surprised when their app still has a cross-site request forgery bug. That’s the core mistake: these are not competing solutions to the same problem. They deal with different threats, at different layers, using different browser behavior. If you only remember one thing, make it this: ...

April 9, 2026 · 7 min · headertest.com