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
Which project does this relate to?
Start
Describe the bug
createStartHandlerrefuses to render a page route when the request'sAcceptheader does not allow HTML, and reports that refusal as
500:router/packages/start-server-core/src/createStartHandler.ts
Lines 558 to 561 in 179d9b9
A failed content negotiation is a client-side condition, so this should be
406 Not Acceptable.500says 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:
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 Acceptableinstead of500 Server Error.Screenshots or Videos
No response
Platform
Additional context
No response