Skip to content

Conversation

@birkskyum
Copy link
Member

@birkskyum birkskyum commented Nov 26, 2025

The behavior is already correct in TanStack Start, but this test make sure that setting multiple cookies work when redirecting. Similar to this issue in SolidStart:

Summary by CodeRabbit

  • New Features

    • Preserves multiple cookies across redirects (session, CSRF, theme) and exposes a redirect flow to validate them.
  • Tests

    • Added end-to-end tests verifying multiple Set-Cookie headers persist through redirects and cookie values are available at the target.
  • Chores

    • Added js-cookie and its type definitions as project dependencies.

✏️ Tip: You can customize this high-level summary in your review settings.

@nx-cloud
Copy link

nx-cloud bot commented Nov 26, 2025

View your CI Pipeline Execution ↗ for commit 16b0fa2

Command Status Duration Result
nx affected --targets=test:eslint,test:unit,tes... ✅ Succeeded 6m 41s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 3s View ↗

☁️ Nx Cloud last updated this comment at 2025-11-26 20:36:19 UTC

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 26, 2025

Walkthrough

Adds end-to-end tests and routes (index + target) for a multi-cookie redirect flow in both React Start and Solid Start; index routes set three cookies server-side then redirect, target routes read and display cookies using js-cookie, and package manifests gain js-cookie and @types/js-cookie.

Changes

Cohort / File(s) Summary
Dependencies
e2e/react-start/basic/package.json, e2e/solid-start/basic/package.json
Added js-cookie (^3.0.5) to dependencies and @types/js-cookie (^3.0.6) to devDependencies.
Route Tree Generation
e2e/react-start/basic/src/routeTree.gen.ts, e2e/solid-start/basic/src/routeTree.gen.ts
Generated route tree extended with multi-cookie-redirect index and target routes; updated route imports, constants, FileRoutes maps, FileRouteTypes, RootRouteChildren, and TanStack Router augmentations to register new routes and parent relationships.
Multi-Cookie Redirect Routes (Index)
e2e/react-start/basic/src/routes/multi-cookie-redirect/index.tsx, e2e/solid-start/basic/src/routes/multi-cookie-redirect/index.tsx
New server-backed index routes that set three cookies (session, csrf, theme) then throw a redirect to /multi-cookie-redirect/target; export Route with loader and null component.
Multi-Cookie Redirect Routes (Target)
e2e/react-start/basic/src/routes/multi-cookie-redirect/target.tsx, e2e/solid-start/basic/src/routes/multi-cookie-redirect/target.tsx
New target routes that read cookies on mount using js-cookie, store values in local state/signals, and render cookie values with data-testid attributes.
E2E Tests
e2e/react-start/basic/tests/redirect.spec.ts, e2e/solid-start/basic/tests/redirect.spec.ts
Added tests verifying multiple Set-Cookie headers are preserved across the redirect: navigate to /multi-cookie-redirect, follow redirect to /multi-cookie-redirect/target, and assert cookie values.

Sequence Diagram

sequenceDiagram
    participant Test as Test/User
    participant Browser as Browser
    participant Server as App Server
    participant Target as Target Route

    Test->>Browser: Navigate to /multi-cookie-redirect
    Browser->>Server: GET /multi-cookie-redirect
    Server->>Server: set-cookie: session=..., csrf=..., theme=...
    Server-->>Browser: 302 Redirect → /multi-cookie-redirect/target
    Browser->>Browser: Store Set-Cookie headers
    Browser->>Target: GET /multi-cookie-redirect/target (follow)
    Target->>Target: On mount/read cookies via js-cookie
    Target->>Test: Render cookie values (data-testid)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Pay attention to generated routeTree files for correct ids/paths and TanStack Router augmentations.
  • Verify server-side cookie setting and redirect semantics in both framework implementations.
  • Confirm tests correctly assert cookie persistence and that js-cookie usage is type-safe with added @types.

Suggested labels

package: react-start-client, package: solid-start-client

Suggested reviewers

  • schiller-manuel

Poem

🐰 I set three cookies with a hop and a twirl,
Then bounced along as the redirects unfurl.
Session, csrf, and theme held tight in their jar—
Followed me safely right to the target star. 🥕🍪

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main objective of the PR, which is to add a test ensuring multiple Set-Cookie headers survive redirects.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch test(start)--make-sure-multiple-cookies-can-be-set-in-redirect

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4e1ef0c and 16b0fa2.

📒 Files selected for processing (2)
  • e2e/react-start/basic/tests/redirect.spec.ts (1 hunks)
  • e2e/solid-start/basic/tests/redirect.spec.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • e2e/react-start/basic/tests/redirect.spec.ts
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use TypeScript strict mode with extensive type safety throughout the codebase

Files:

  • e2e/solid-start/basic/tests/redirect.spec.ts
🧠 Learnings (1)
📚 Learning: 2025-10-01T18:30:26.591Z
Learnt from: schiller-manuel
Repo: TanStack/router PR: 5330
File: packages/router-core/src/router.ts:2231-2245
Timestamp: 2025-10-01T18:30:26.591Z
Learning: In `packages/router-core/src/router.ts`, the `resolveRedirect` method intentionally strips the router's origin from redirect URLs when they match (e.g., `https://foo.com/bar` → `/bar` for same-origin redirects) while preserving the full URL for cross-origin redirects. This logic should not be removed or simplified to use `location.publicHref` directly.

Applied to files:

  • e2e/solid-start/basic/tests/redirect.spec.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Test
  • GitHub Check: Preview
🔇 Additional comments (1)
e2e/solid-start/basic/tests/redirect.spec.ts (1)

215-232: Multi-cookie redirect E2E test looks correct and aligned with the route behavior

The flow (navigate to /multi-cookie-redirect, wait for the redirect, then assert target visibility and all three cookie-driven values) accurately exercises the multi–Set-Cookie redirect scenario and should guard well against regressions in cookie handling across redirects.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 26, 2025

More templates

@tanstack/arktype-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/arktype-adapter@5978

@tanstack/directive-functions-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/directive-functions-plugin@5978

@tanstack/eslint-plugin-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/eslint-plugin-router@5978

@tanstack/history

npm i https://pkg.pr.new/TanStack/router/@tanstack/history@5978

@tanstack/nitro-v2-vite-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/nitro-v2-vite-plugin@5978

@tanstack/react-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router@5978

@tanstack/react-router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-devtools@5978

@tanstack/react-router-ssr-query

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-ssr-query@5978

@tanstack/react-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start@5978

@tanstack/react-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-client@5978

@tanstack/react-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-server@5978

@tanstack/router-cli

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-cli@5978

@tanstack/router-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-core@5978

@tanstack/router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools@5978

@tanstack/router-devtools-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools-core@5978

@tanstack/router-generator

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-generator@5978

@tanstack/router-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-plugin@5978

@tanstack/router-ssr-query-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-ssr-query-core@5978

@tanstack/router-utils

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-utils@5978

@tanstack/router-vite-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-vite-plugin@5978

@tanstack/server-functions-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/server-functions-plugin@5978

@tanstack/solid-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router@5978

@tanstack/solid-router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-devtools@5978

@tanstack/solid-router-ssr-query

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-ssr-query@5978

@tanstack/solid-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start@5978

@tanstack/solid-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-client@5978

@tanstack/solid-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-server@5978

@tanstack/start-client-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-client-core@5978

@tanstack/start-plugin-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-plugin-core@5978

@tanstack/start-server-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-core@5978

@tanstack/start-static-server-functions

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-static-server-functions@5978

@tanstack/start-storage-context

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-storage-context@5978

@tanstack/valibot-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/valibot-adapter@5978

@tanstack/virtual-file-routes

npm i https://pkg.pr.new/TanStack/router/@tanstack/virtual-file-routes@5978

@tanstack/zod-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/zod-adapter@5978

commit: 16b0fa2

@birkskyum birkskyum merged commit 430f268 into main Nov 26, 2025
6 checks passed
@birkskyum birkskyum deleted the test(start)--make-sure-multiple-cookies-can-be-set-in-redirect branch November 26, 2025 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants