diff --git a/.changeset/gentle-scissors-bow.md b/.changeset/gentle-scissors-bow.md new file mode 100644 index 000000000000..4e9387779d9c --- /dev/null +++ b/.changeset/gentle-scissors-bow.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fixes an issue where the origin check middleware run for prendered pages diff --git a/packages/astro/src/core/app/middlewares.ts b/packages/astro/src/core/app/middlewares.ts index a60b6baf4081..1c7d6cde04cf 100644 --- a/packages/astro/src/core/app/middlewares.ts +++ b/packages/astro/src/core/app/middlewares.ts @@ -20,7 +20,11 @@ const FORM_CONTENT_TYPES = [ */ export function createOriginCheckMiddleware(): MiddlewareHandler { return defineMiddleware((context, next) => { - const { request, url } = context; + const { request, url, isPrerendered } = context; + // Prerendered pages should be excluded + if (isPrerendered) { + return next(); + } const contentType = request.headers.get('content-type'); if (contentType) { if (FORM_CONTENT_TYPES.includes(contentType.toLowerCase())) {