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); }