-
-
Notifications
You must be signed in to change notification settings - Fork 602
Open
Labels
Description
Summary
SSR GraphQL requests can lose authenticated context because the server Apollo client overwrites the Cookie header with only csrftoken.
Affected code
frontend/src/server/apolloClient.ts
Problem
In the server Apollo setContext, headers are set as:
X-CSRFToken: <token>Cookie: csrftoken=<token>
This replaces the full incoming cookie header instead of preserving/merging it, so session/auth cookies are dropped.
Why this is an issue
Any SSR GraphQL operation that depends on authenticated session cookies may behave as unauthenticated (or inconsistently), because the outgoing request no longer carries full cookie state.
Reproduction
- Sign in to Nest in browser (session/auth cookies present).
- Open a route that performs server-side GraphQL via
server/apolloClient. - Add temporary debug logging in
frontend/src/server/apolloClient.tsto inspect outbound request headers. - Observe
Cookieheader contains onlycsrftoken=...and omits other cookies.
Expected
Server-side GraphQL requests should preserve incoming cookies (including session/auth cookies) and include CSRF safely.
Actual
Cookie is overwritten to only csrftoken=....
Proposed fix
- Preserve full incoming cookie header from request context.
- Merge or append CSRF cookie/token without discarding existing cookies.
- Keep
X-CSRFTokenbehavior intact.
Acceptance criteria
- SSR Apollo requests include original session/auth cookies.
- CSRF token handling remains functional.
- Add regression test for header propagation/merge behavior in server Apollo client.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
In progress