mirror of
https://github.com/withastro/astro.git
synced 2025-02-03 22:29:08 -05:00
Fix 404 response leading to an infinite loop when there is no 404 page (#8136)
* fix: 404 response leads to infinite loop * chore: changeset --------- Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
This commit is contained in:
parent
8c0a4ed106
commit
97c8760d78
2 changed files with 10 additions and 1 deletions
5
.changeset/lemon-comics-jump.md
Normal file
5
.changeset/lemon-comics-jump.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'astro': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix 404 response leading to an infinite loop when there is no 404 page.
|
|
@ -259,7 +259,7 @@ export async function handleRoute({
|
||||||
await writeWebResponse(incomingResponse, response);
|
await writeWebResponse(incomingResponse, response);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (result.status === 404) {
|
if (result.status === 404 && has404Route(manifestData)) {
|
||||||
const fourOhFourRoute = await matchRoute('/404', env, manifestData);
|
const fourOhFourRoute = await matchRoute('/404', env, manifestData);
|
||||||
return handleRoute({
|
return handleRoute({
|
||||||
...options,
|
...options,
|
||||||
|
@ -380,3 +380,7 @@ function getStatus(matchedRoute?: MatchedRoute): 404 | 500 | undefined {
|
||||||
if (matchedRoute.route.route === '/404') return 404;
|
if (matchedRoute.route.route === '/404') return 404;
|
||||||
if (matchedRoute.route.route === '/500') return 500;
|
if (matchedRoute.route.route === '/500') return 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function has404Route(manifest: ManifestData): RouteData | undefined {
|
||||||
|
return manifest.routes.find((route) => route.route === '/404')
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue