Repository navigation
feat: add cookie passthrough helpers for server function cookie forwarding - #14
Conversation
Exports initVtexCookieProviders() from @decocms/start/sdk that wires TanStack Start request/response headers to the VTEX client cookie providers (setRequestCookieProvider / setResponseCookieForwarder from @decocms/apps/vtex). Sites call this once in setup.ts after setVtexFetch() to enable transparent cookie propagation for all VTEX checkout, session, and auth actions -- no per-server-function changes needed. Depends on: decocms/apps-start#3 Co-Authored-By: Claude Opus 4.6 <[email protected]>
Replace initVtexCookieProviders (which imported directly from @decocms/apps/vtex) with two generic helpers: - getRequestCookieHeader(): reads Cookie header from TanStack Start request - forwardResponseCookies(cookies): appends Set-Cookie to the response These are framework-bound but app-agnostic. Any commerce app (VTEX, Shopify, Wake) can use them as cookie providers. The site wires them in setup.ts: setRequestCookieProvider(getRequestCookieHeader); setResponseCookieForwarder(forwardResponseCookies); Co-Authored-By: Claude Opus 4.6 <[email protected]>
There was a problem hiding this comment.
1 issue found across 3 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/sdk/cookiePassthrough.ts">
<violation number="1" location="src/sdk/cookiePassthrough.ts:44">
P1: `setResponseHeader` replaces the response's `Set-Cookie` header instead of appending to existing cookies, so this helper can drop cookies already set elsewhere in the request.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
There was a problem hiding this comment.
2 issues found across 2 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/sdk/index.ts">
<violation number="1" location="src/sdk/index.ts:63">
P1: This adds the barrel export, but the documented `@decocms/start/sdk/vtexCookieProviders` entrypoint is still missing from `package.json`, so consumers following the example will not be able to import it.</violation>
</file>
<file name="src/sdk/vtexCookieProviders.ts">
<violation number="1" location="src/sdk/vtexCookieProviders.ts:46">
P1: `Set-Cookie` forwarding should append cookies instead of resetting the header, or earlier VTEX cookies can be lost when multiple responses set cookies in one request.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Address code review feedback (identified by cubic): - forwardResponseCookies now reads existing Set-Cookie headers via getSetCookie() and appends new ones, preventing earlier cookies from being dropped when multiple API calls set cookies in one request - Add ./sdk/cookiePassthrough entrypoint to package.json exports Co-Authored-By: Claude Opus 4.6 <[email protected]>
Prevents CDN/edge from caching responses that carry Set-Cookie headers, which would serve one user's session cookies to another. Co-Authored-By: Claude Opus 4.6 <[email protected]>
There was a problem hiding this comment.
1 issue found across 2 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/sdk/cookiePassthrough.ts">
<violation number="1" location="src/sdk/cookiePassthrough.ts:58">
P0: This `no-store` header does not stop deco-start's own edge cache, so responses that forward `Set-Cookie` can still be cached and replayed to other users.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
The previous cache-control header in cookiePassthrough was ineffective because workerEntry overwrites Cache-Control before storing in the Cloudflare Cache API. Move the protection to workerEntry itself: responses with Set-Cookie now bypass cache storage entirely and return with Cache-Control: private, no-store to prevent any downstream caching. This prevents one user's session/auth cookies from being cached and served to another user. Co-Authored-By: Claude Opus 4.6 <[email protected]>
There was a problem hiding this comment.
1 issue found across 2 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/sdk/workerEntry.ts">
<violation number="1" location="src/sdk/workerEntry.ts:734">
P1: Clear inherited `CDN-Cache-Control` in the Set-Cookie bypass branch, or Cloudflare can still cache this response despite the new `private` Cache-Control.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Cloudflare prioritizes CDN-Cache-Control over Cache-Control. If the origin response had CDN-Cache-Control set (e.g. from cacheHeaders()), our private/no-store Cache-Control would be ignored and the response with Set-Cookie headers could still be cached at the edge, leaking one user's session cookies to another. Co-Authored-By: Claude Opus 4.6 <[email protected]>
|
🎉 This PR is included in version 0.23.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
…anStack Start, esbuild) (#832) Closes the open Dependabot alerts in one PR, with the lockfile. The Dependabot PRs (#811, #828, #747) only touch `package.json`, so they all fail `bun install --frozen-lockfile` in CI. | Package | From | To | Alerts | |---|---|---|---| | `react-server-dom-webpack` (tanstack-rsc-smoke) | 19.2.7 | 19.2.9 | #19, critical: RSC RCE, GHSA-xqc2-xf4c-x3h3 | | `react` / `react-dom` (all pinned workspaces) | 19.2.7 | 19.2.9 | peer floor of the above | | `next` (nextjs, compat-v7, nextjs-binding-smoke) | 16.3.8 | 16.4.6 | #10–12, #14, #15, #17, #18, #20–22 | | `@tanstack/react-start` (tanstack, compat-v7, smokes) | 1.168.58 | 1.168.61 | #2–4, #7, #9 | | `@tanstack/react-router` | 1.170.39 | 1.170.42 | the version react-start 1.168.61 pins, so it stays a single copy | | `esbuild` (blocks, tanstack, compat-v7) | ^0.27.3 | ^0.28.2 | #5, #6, #8 (low) | `bun.lock` was regenerated with bun 1.3.5 (the `packageManager`). React dedupes to a single 19.2.9 at the root, with no nested copies. Vite still has its own transitive `[email protected]` (its own range); that is outside our manifests. Supersedes #811, #828 and #747. ### Verified locally (bun 1.3.5, node 24) - `bun install --frozen-lockfile` ✅ - `bun run typecheck` ✅ · `bun run lint` ✅ - `bun x vitest run`: 3388 passed, 0 failed ✅ (includes `tests/release.test.ts`) - `examples/tanstack-worker-smoke`: build + smoke ✅ - `examples/nextjs-binding-smoke`: build + smoke ✅ - `examples/tanstack-rsc-smoke`: build + typecheck ✅ 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Bumps several dependencies to clear open Dependabot security alerts, including a critical RCE in `react-server-dom-webpack` (GHSA-xqc2-xf4c-x3h3). The lockfile was regenerated so `bun install --frozen-lockfile` passes — React dedupes to a single 19.2.9 copy. **Dependencies** - `react`, `react-dom`, and `react-server-dom-webpack` 19.2.7 → 19.2.9 - `next` 16.3.8 → 16.4.6 - `@tanstack/react-start` 1.168.58 → 1.168.61, with `@tanstack/react-router` 1.170.42 - `esbuild` ^0.27.3 → ^0.28.2; Vite's own transitive `[email protected]` is untouched - Typecheck, lint, the full test suite (3388 passed), and the Next.js and TanStack smoke builds all pass <sup>Written for commit 123acc8. Summary will update on new commits.</sup> <a href="https://cubic.dev/pr/decocms/blocks/pull/832?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="View guided diff" src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a> <a href="https://www.cubic.dev/action/auto-fix/pr/decocms/blocks/832?returnTo=https%3A%2F%2Fgithub.com%2Fdecocms%2Fblocks%2Fpull%2F832&source=description" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img alt="Turn on auto-fix" src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a> <!-- End of auto-generated description by cubic. --> Co-authored-by: Claude Opus 5.5 <[email protected]>
Summary
getRequestCookieHeader()andforwardResponseCookies()exported from@decocms/start/sdk/cookiePassthrough@decocms/apps— deco-start stays cleanUsage
Sites wire them in
setup.ts:What the helpers do
getRequestCookieHeader()— reads theCookieheader from the current TanStack Start request context (safe outside request scope, returnsundefined)forwardResponseCookies(cookies)— appendsSet-Cookieheaders to the current TanStack Start response (safe outside request scope, no-op)Depends on
setRequestCookieProvider/setResponseCookieForwarderto the VTEX client)Test plan
Generated with Claude Code