Commit d55fbcf
committed
fix(auth): add withCredentials and fix CORS to persist session cookies
Login.tsx and Signup.tsx were sending axios POST requests without
{ withCredentials: true }, so the browser silently discarded the
Set-Cookie header on every cross-origin login/signup response. No
session cookie was ever stored, making every subsequent request
appear unauthenticated.
Changes:
- src/pages/Login/Login.tsx: pass { withCredentials: true } as the
third argument to axios.post for /api/auth/login
- src/pages/Signup/Signup.tsx: same fix for /api/auth/signup; also
remove the stale "Include cookies for session" comment that noted
the intent but was never fulfilled
- backend/server.js: replace cors('*') with a credentials-aware
config (origin: FRONTEND_URL, credentials: true); a wildcard origin
is rejected by browsers when credentials are present, so a specific
origin is required for Set-Cookie to be honoured
Fixes #4141 parent 6c6bc3e commit d55fbcf
2 files changed
Lines changed: 10 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
34 | 38 | | |
35 | 39 | | |
36 | 40 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
87 | | - | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
88 | 90 | | |
89 | | - | |
| 91 | + | |
90 | 92 | | |
91 | 93 | | |
92 | 94 | | |
| |||
0 commit comments