diff --git a/packages/astro/src/core/app/base.ts b/packages/astro/src/core/app/base.ts index 4006adda0223..73184a688b3e 100644 --- a/packages/astro/src/core/app/base.ts +++ b/packages/astro/src/core/app/base.ts @@ -91,7 +91,7 @@ export interface RenderErrorOptions { */ error?: unknown; clientAddress: string | undefined; - prerenderedErrorPageFetch: (url: ErrorPagePath) => Promise; + prerenderedErrorPageFetch: ((url: ErrorPagePath) => Promise) | undefined; } type ErrorPagePath = @@ -500,7 +500,7 @@ export abstract class BaseApp

{ if (errorRouteData.prerender) { const maybeDotHtml = errorRouteData.route.endsWith(`/${status}`) ? '.html' : ''; const statusURL = new URL(`${this.baseWithoutTrailingSlash}/${status}${maybeDotHtml}`, url); - if (statusURL.toString() !== request.url) { + if (statusURL.toString() !== request.url && prerenderedErrorPageFetch) { const response = await prerenderedErrorPageFetch(statusURL.toString() as ErrorPagePath); // In order for the response of the remote to be usable as a response diff --git a/packages/astro/src/core/build/app.ts b/packages/astro/src/core/build/app.ts index f0d4958836f9..cecc2fef21e6 100644 --- a/packages/astro/src/core/build/app.ts +++ b/packages/astro/src/core/build/app.ts @@ -31,7 +31,10 @@ export class BuildApp extends BaseApp { if (options.status === 500) { throw options.error; } else { - return super.renderError(request, options); + return super.renderError(request, { + ...options, + prerenderedErrorPageFetch: undefined + }); } } }