Skip to content

Commit 70bbec9

Browse files
authored
chore: address feedback from #7754 (#7906)
1 parent 1d9e34b commit 70bbec9

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

packages/astro/src/core/app/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ export class App {
273273
}
274274

275275
/**
276-
* If is a known error code, try sending the according page (e.g. 404.astro / 500.astro).
276+
* If it is a known error code, try sending the according page (e.g. 404.astro / 500.astro).
277277
* This also handles pre-rendered /404 or /500 routes
278278
*/
279279
async #renderError(
@@ -319,8 +319,10 @@ export class App {
319319
const { status, statusText, headers } = oldResponse;
320320

321321
return new Response(newResponse.body, {
322+
// If the original status was 200 (default), override it with the new status (probably 404 or 500)
323+
// Otherwise, the user set a specific status while rendering and we should respect that one
322324
status: status === 200 ? newResponse.status : status,
323-
statusText,
325+
statusText: status === 200 ? newResponse.statusText : statusText,
324326
headers: new Headers(Array.from(headers)),
325327
});
326328
}

0 commit comments

Comments
 (0)