TanStackT
TanStack2mo ago
1 reply
spotty-amber

Setting status-code from loader

Has anyone found a good way to set the response status code from a loader during SSR? setResponseStatus does nothing.

I need to set the status code to 404, but without throwing an error in the loader. Ideally, I would like to render the page as usual using the loader's result, but use the status code to signal indexers, etc., that the site is "expired".

Alternative approaches:

1. Throw the result of notFound() and fetch the data from the API on the client (outside of the loader).
2. Using middlewares somehow propagating status code through headers and similar, and map the response object....
3. ???
Was this page helpful?