Skip to content

redirect() ignores Headers(), making it impossible to set multiple headers with the same name #4038

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
frenzzy opened this issue Apr 24, 2025 · 0 comments
Labels
start Everything about TanStack Start

Comments

@frenzzy
Copy link

frenzzy commented Apr 24, 2025

Which project does this relate to?

Start

Describe the bug

It is not possible to set multiple headers using the redirect() method with the Headers() interface, because all headers are ignored in this case:

import { redirect } from '@tanstack/react-router';
import { createServerFn } from '@tanstack/react-start';

export const action = createServerFn({ method: 'GET' }).handler(() => {
  const headers = new Headers()
  headers.append('x-example', 'a')
  headers.append('x-example', 'b')
  throw redirect({ to: '/', headers }) // no response headers
  // throw redirect({ to: '/', headers: { 'x-example': 'c' } }) // works
})

Your Example Website or App

https://tanstack.com/start/latest/docs/framework/react/examples/start-basic?path=examples%2Freact%2Fstart-basic%2Fsrc%2Futils%2Fposts.tsx

Steps to Reproduce the Bug or Issue

  1. Create a server function with redirect()
  2. Pass a Headers() object to redirect()
  3. Make a request and check the response headers

Expected behavior

Headers should be present in the response

Screenshots or Videos

No response

Platform

  • OS: any
  • Browser: any
  • Version: latest on Apr 24, 2025 (1.117.0)

Additional context

No response

@frenzzy frenzzy changed the title Method redirect() ignores Headers(), making impossible to set multiple similar headers at once redirect() ignores Headers(), making it impossible to set multiple headers with the same name Apr 24, 2025
@SeanCassiere SeanCassiere added the start Everything about TanStack Start label Apr 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
start Everything about TanStack Start
Projects
None yet
Development

No branches or pull requests

2 participants