Creating a new Response with a Status Code of 404 leads to an infinite loop when the /404.astro page is absent. #10581
Labels
- P4: important
Violate documented behavior or significantly impacts performance (priority)
feat: error pages
Related to 404 and 500 handling (scope)
regression
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
In the past it was feasible to generate Responses bearing the 404 status code. However, in the current setup (version 4.5.x and above), this process triggers an infinite loop due to Astro's subsequent search for the missing /404.astro page. To circumvent this loop, I opt not to furnish a /404.astro page. This choice stems from my desire to refrain from redirecting users to a dedicated 404 page. Instead, I intend to furnish a 404 Code directly while retaining the requested URL's context.
The problem exists only in dev mode and was already reported and fixed here: #8100
But with the new version 4.5.x the bug came back.
What's the expected result?
I would expect an Response with the status code 404 without redirecting to the missing /404.astro
return new Response("custom 404 html content", { status: 404 });
Link to Minimal Reproducible Example
https://stackblitz.com/edit/stackblitz-starters-jcjvxf?file=response-with-404-code%2Fsrc%2Fpages%2F[...path].astro
Participation
The text was updated successfully, but these errors were encountered: