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)
- Add the SPA origin to
config/sanctum.phpstateful. - Set
supports_credentials => trueinconfig/cors.php. - Call
/sanctum/csrf-cookieonce before the first write.
Tokens (mobile, server-to-server)
Pass the token to the client and skip cookies. Fetch usescredentials: '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.
