You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
apps-vtex/tanstack: vtex_session/vtex_segment duplicated (host-only + Domain) — server path drops Domain, dedup ignores it #643
On a TanStack storefront the browser ends up holding twovtex_session and twovtex_segment cookies:
Through the /api/* proxy, VTEX Set-Cookie is rewritten to Domain=<host> (utils/proxy.ts → rewriteSetCookieDomain). That matches Fresh's proxySetCookie.
On the server path, vtexFetchWithCookies (SSR, /deco/invoke) forwards the cookie host-only. rewriteCookieDomain in client.ts only replaces an existing Domain= attribute, and VTEX sends none.
The browser treats a host-only cookie and a Domain=<host> cookie as different cookies, so both are sent on every request. SSR and VTEX then each read a different copy.
Impact we measured (oficina-tanstack, Prime account): the SSR rendered Prime prices, but /api/segments answered priceTables: null (production: oficinaprime).
Second issue
deduplicateSetCookies in @decocms/tanstack/src/sdk/workerEntry.ts keys on the cookie name only. So a response can't expire the host-only copy and write the Domain one at the same time: one of the two lines is dropped.
Repro
# raw VTEX: no Domain
curl -sD- -o/dev/null -X PATCH https://<account>.vtexcommercestable.com.br/api/sessions -d '{"public":{}}' | grep -i set-cookie
# proxy: Domain=<host>; server-side invoke/SSR: no Domain → two cookies in the jar
Suggested fix
rewriteCookieDomain: when host is known, add Domain=<host> if the attribute is absent, like proxySetCookie.
deduplicateSetCookies: key on name + Domain + Path.
Activity