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 <natemoo-re@users.noreply.github.com>
This commit is contained in:
Arsh 2023-08-19 02:21:46 +05:30 committed by GitHub
parent be2d60285e
commit 4c15c06969
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 9 deletions

View file

@ -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.

View file

@ -38,15 +38,7 @@ const preview: CreatePreviewServer = async function ({
} }
const handler: http.RequestListener = (req, res) => { const handler: http.RequestListener = (req, res) => {
ssrHandler(req, res, (ssrErr: any) => { ssrHandler(req, res);
if (ssrErr) {
res.writeHead(500);
res.end(ssrErr.toString());
} else {
res.writeHead(404);
res.end();
}
});
}; };
const baseWithoutTrailingSlash: string = base.endsWith('/') const baseWithoutTrailingSlash: string = base.endsWith('/')