diff options
author | 2023-08-01 13:24:02 -0500 | |
---|---|---|
committer | 2023-08-01 13:24:02 -0500 | |
commit | 70bbec9c6115ac3234cbdba8ef9c96a6c1ac6f81 (patch) | |
tree | 9be33dfc23458e7ef7811a41a3d173760a7d5bd4 | |
parent | 1d9e34b1367746e51ba7c6614799d0f4522612d2 (diff) | |
download | astro-70bbec9c6115ac3234cbdba8ef9c96a6c1ac6f81.tar.gz astro-70bbec9c6115ac3234cbdba8ef9c96a6c1ac6f81.tar.zst astro-70bbec9c6115ac3234cbdba8ef9c96a6c1ac6f81.zip |
chore: address feedback from #7754 (#7906)
-rw-r--r-- | packages/astro/src/core/app/index.ts | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/packages/astro/src/core/app/index.ts b/packages/astro/src/core/app/index.ts index 37c972287..288385598 100644 --- a/packages/astro/src/core/app/index.ts +++ b/packages/astro/src/core/app/index.ts @@ -273,7 +273,7 @@ export class App { } /** - * If is a known error code, try sending the according page (e.g. 404.astro / 500.astro). + * If it is a known error code, try sending the according page (e.g. 404.astro / 500.astro). * This also handles pre-rendered /404 or /500 routes */ async #renderError( @@ -319,8 +319,10 @@ export class App { const { status, statusText, headers } = oldResponse; return new Response(newResponse.body, { + // If the original status was 200 (default), override it with the new status (probably 404 or 500) + // Otherwise, the user set a specific status while rendering and we should respect that one status: status === 200 ? newResponse.status : status, - statusText, + statusText: status === 200 ? newResponse.statusText : statusText, headers: new Headers(Array.from(headers)), }); } |