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:
parent
be2d60285e
commit
4c15c06969
2 changed files with 6 additions and 9 deletions
5
.changeset/rude-ducks-exist.md
Normal file
5
.changeset/rude-ducks-exist.md
Normal 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.
|
|
@ -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('/')
|
||||||
|
|
Loading…
Reference in a new issue