Skip to content

Start: page route returns 500 when Accept excludes HTML #7913

Description

@ollipa

Which project does this relate to?

Start

Describe the bug

createStartHandler refuses to render a page route when the request's Accept
header does not allow HTML, and reports that refusal as 500:

Response.json(
{ error: 'Only HTML requests are supported here' },
{ status: 500 },
),

A failed content negotiation is a client-side condition, so this should be
406 Not Acceptable. 500 says the server malfunctioned, and nothing did.

Complete minimal reproducer

reproduction doesn't need any custom code

Steps to Reproduce the Bug

Against any Start app, on any page (non-server) route:

  curl -i -H 'Accept: application/json' https://example.com/
  curl -i -H 'Accept: image/webp'       https://example.com/

Both return 500 {"error":"Only HTML requests are supported here"}. Accept: /, a browser Accept, and an absent header all return 200.

Expected behavior

Should return 406 Not Acceptable instead of 500 Server Error.

Screenshots or Videos

No response

Platform

  • @tanstack/react-start 1.168.32
  • @tanstack/start-server-core 1.169.17 (current latest)

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions