Skip to content

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

Description

@frenzzy

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    startEverything about TanStack Start

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions