From 4c15c069691ca25efcb9ebb7d9b45605cd136ed3 Mon Sep 17 00:00:00 2001 From: Arsh <69170106+lilnasy@users.noreply.github.com> Date: Sat, 19 Aug 2023 02:21:46 +0530 Subject: [PATCH] fix(node): delegate preview's not found and error handling to core/app (#8141) * fix(node): delegate preview's not found and error handling to core/app * add changeset --------- Co-authored-by: Nate Moore --- .changeset/rude-ducks-exist.md | 5 +++++ packages/integrations/node/src/preview.ts | 10 +--------- 2 files changed, 6 insertions(+), 9 deletions(-) create mode 100644 .changeset/rude-ducks-exist.md diff --git a/.changeset/rude-ducks-exist.md b/.changeset/rude-ducks-exist.md new file mode 100644 index 000000000000..8c4147904bac --- /dev/null +++ b/.changeset/rude-ducks-exist.md @@ -0,0 +1,5 @@ +--- +'@astrojs/node': patch +--- + +Fixed an issue where the preview mode handled 404 and 500 routes differently from running app with node directly. diff --git a/packages/integrations/node/src/preview.ts b/packages/integrations/node/src/preview.ts index 4a4db46323f5..62a4301c1d1e 100644 --- a/packages/integrations/node/src/preview.ts +++ b/packages/integrations/node/src/preview.ts @@ -38,15 +38,7 @@ const preview: CreatePreviewServer = async function ({ } const handler: http.RequestListener = (req, res) => { - ssrHandler(req, res, (ssrErr: any) => { - if (ssrErr) { - res.writeHead(500); - res.end(ssrErr.toString()); - } else { - res.writeHead(404); - res.end(); - } - }); + ssrHandler(req, res); }; const baseWithoutTrailingSlash: string = base.endsWith('/')