From facf8016e249058d6e5cce7a0e7ef6c42fc854ad Mon Sep 17 00:00:00 2001 From: Ben Holmes Date: Mon, 18 Apr 2022 18:12:30 -0400 Subject: [PATCH] Fix: show correct error log on 5xx error (#3137) * fix: show correct error log on 5xx error * chore: changeset --- .changeset/wild-geckos-rule.md | 5 +++++ packages/astro/src/vite-plugin-astro-server/index.ts | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .changeset/wild-geckos-rule.md diff --git a/.changeset/wild-geckos-rule.md b/.changeset/wild-geckos-rule.md new file mode 100644 index 000000000..7b89075e8 --- /dev/null +++ b/.changeset/wild-geckos-rule.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fix: show correct stacktrace on dev server errors, instead of cryptic "package.json" error diff --git a/packages/astro/src/vite-plugin-astro-server/index.ts b/packages/astro/src/vite-plugin-astro-server/index.ts index a1d897609..485f16282 100644 --- a/packages/astro/src/vite-plugin-astro-server/index.ts +++ b/packages/astro/src/vite-plugin-astro-server/index.ts @@ -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); }