0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-16 21:46:22 -05:00

Fix: show correct error log on 5xx error (#3137)

* fix: show correct error log on 5xx error

* chore: changeset
This commit is contained in:
Ben Holmes 2022-04-18 18:12:30 -04:00 committed by GitHub
parent efa6f7d662
commit facf8016e2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Fix: show correct stacktrace on dev server errors, instead of cryptic "package.json" error

View file

@ -128,7 +128,7 @@ async function handle500Response(
res: http.ServerResponse,
err: any
) {
const pathname = decodeURI(new URL(origin + req.url).pathname);
const pathname = decodeURI(new URL('./index.html', origin + req.url).pathname);
const html = serverErrorTemplate({
statusCode: 500,
title: 'Internal Error',
@ -137,7 +137,7 @@ async function handle500Response(
url: err.url || undefined,
stack: stripAnsi(err.stack),
});
const transformedHtml = await viteServer.transformIndexHtml(pathname, html, pathname);
const transformedHtml = await viteServer.transformIndexHtml(pathname, html);
writeHtmlResponse(res, 500, transformedHtml);
}