Skip to content

Commit

Permalink
Fix: show correct error log on 5xx error (#3137)
Browse files Browse the repository at this point in the history
* fix: show correct error log on 5xx error

* chore: changeset
  • Loading branch information
bholmesdev committed Apr 18, 2022
1 parent efa6f7d commit facf801
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/wild-geckos-rule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Fix: show correct stacktrace on dev server errors, instead of cryptic "package.json" error
4 changes: 2 additions & 2 deletions packages/astro/src/vite-plugin-astro-server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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);
}

Expand Down

0 comments on commit facf801

Please sign in to comment.