Skip to content

Wrap SPA auth endpoints with 'web' middleware so session cookies persist - #30

Closed
RichPC wants to merge 1 commit into
k2so-dev:mainfrom
RichPC:fix/web-middleware-auth
Closed

Wrap SPA auth endpoints with 'web' middleware so session cookies persist#30
RichPC wants to merge 1 commit into
k2so-dev:mainfrom
RichPC:fix/web-middleware-auth

Conversation

@RichPC

@RichPC RichPC commented Oct 24, 2025

Copy link
Copy Markdown

Problem

  • SPA auth endpoints were registered under API routes without the 'web' middleware. Session middleware was not applied, so login didn't persist authentication.

Fix

  • Wrap SPA auth endpoints (login, register, social callbacks, password, verification) in Route::middleware('web')->group(...).

Verification

  • Reproduced login flow locally; session and auth persisted and /api/v1/user returns authenticated user.

@RichPC

RichPC commented Feb 21, 2026

Copy link
Copy Markdown
Author

I've since found this causes problems. Having 'web' and 'auth:sanctum' middleware on route group in laravel 12 can cause session to be droped, e.g. login - works, get request works (but comes back with a new session cookie) second get request to same route fails because session got rotated.

@RichPC RichPC closed this Feb 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant