-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Infinite loop when middleware creates a 404 response #10735
Copy link
Copy link
Closed
Labels
- P5: urgentFix build-breaking bugs affecting most users, should be released ASAP (priority)Fix build-breaking bugs affecting most users, should be released ASAP (priority)feat: error pagesRelated to 404 and 500 handling (scope)Related to 404 and 500 handling (scope)feat: middlewareRelated to middleware (scope)Related to middleware (scope)regression
Description
Astro Info
Astro v4.5.17
Node v20.11.1
System Windows (x64)
Package Manager unknown
Output static
Adapter none
Integrations none
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
Quoting #8100 (comment)
...there is no way now to return any 404 in the middleware, it always ends up in an infinite loop, even if I create a static 404 page. I'm now forced to diverge from security best practices and return a 403 instead. This way there is no endless loop.
What's the expected result?
Server does NOT recursively call itself. Context: "Recursive rerouting" section of withastro/roadmap#681.
Link to Minimal Reproducible Example
| return new Response(response.body, { ...response, status: 404 }) |
astro/packages/astro/test/custom-404-implicit-rerouting.test.js
Lines 35 to 36 in 2acea4d
| it.skip( | |
| 'dev server stays responsive', |
Participation
- I am willing to submit a pull request for this issue.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
- P5: urgentFix build-breaking bugs affecting most users, should be released ASAP (priority)Fix build-breaking bugs affecting most users, should be released ASAP (priority)feat: error pagesRelated to 404 and 500 handling (scope)Related to 404 and 500 handling (scope)feat: middlewareRelated to middleware (scope)Related to middleware (scope)regression