Skip to main content
The guard and the middleware group have to match. The web guard reads the user out of the session, and Laravel’s api group never starts one. The installer pairs them; if you edit config by hand, keep them in sync. Getting this wrong is quiet rather than loud: reads keep working (they are public) and every write comes back 401. Pro resolves the acting user through ApiAuth and ResolveCommentifyGuard middleware, which calls Auth::shouldUse() for the configured guard on every API request.

Same-origin (web)

Nothing else to do. The browser sends the session cookie. The SDK reads Laravel’s XSRF-TOKEN cookie and echoes it as X-XSRF-TOKEN, so CSRF passes without setup.

Cross-origin SPA (sanctum)

  1. Add the SPA origin to config/sanctum.php stateful.
  2. Set supports_credentials => true in config/cors.php.
  3. Call /sanctum/csrf-cookie once before the first write.

Tokens (mobile, server-to-server)

Pass the token to the client and skip cookies. Fetch uses credentials: 'same-origin' when a token is set, and sends Authorization: Bearer ….

Who can write

Read-only mode (core.read_only) rejects all writes with 423 and code read_only. Comment bans reject with 403 and code comment_banned. See API errors.
Last modified on September 12, 2026