Skip to content

Commit

Permalink
fix(node): delegate preview's not found and error handling to core/app (
Browse files Browse the repository at this point in the history
#8141)

* fix(node): delegate preview's not found and error handling to core/app

* add changeset

---------

Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
  • Loading branch information
lilnasy and natemoo-re authored Aug 18, 2023
1 parent be2d602 commit 4c15c06
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/rude-ducks-exist.md
Original file line number Diff line number Diff line change
@@ -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.
10 changes: 1 addition & 9 deletions packages/integrations/node/src/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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('/')
Expand Down

0 comments on commit 4c15c06

Please sign in to comment.