The session cookie is set with `SameSite=Lax` (see `servers/dating/http.mjs:sessionCookie`). Browsers treat `http://localhost` and `http://127.0.0.1` as DIFFERENT sites, so when SvelteKit dev runs on `localhost:5173` and the API client hard-codes `127.0.0.1:8787`, the cookie set by `/api/auth/login` is dropped on every subsequent fetch. End result the user reported: login appears to "do nothing" — the request really did succeed, but the next `/api/session` probe arrives without the cookie and the client thinks the user is anonymous again. Fix: derive the API base from `window.location.hostname` at runtime (falling back to `127.0.0.1` on SSR / vitest where `window` doesn't exist). Now the page on `localhost:5173` talks to `localhost:8787` and the page on `127.0.0.1:5173` talks to `127.0.0.1:8787` — both same-site pairs, so `SameSite=Lax` keeps the cookie attached on fetch. `DATING_API_DEFAULT_BASE` stays exported as a deprecated literal so external callers that imported it don't break; new code should use `resolveDatingApiBase()` or pass `options.base` explicitly. The server's CORS allowlist already covers both `localhost:5173` and `127.0.0.1:5173`, so no server change is needed. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>master
parent
c6392c317f
commit
27198b53ea
Loading…
Reference in new issue