From 6c22e619404a5768eacfa7443c5dabac2f98c695 Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Fri, 25 Oct 2024 11:10:26 +0100 Subject: [PATCH] fix(routing): don't check headers for prenredered pages --- .changeset/gentle-scissors-bow.md | 5 +++++ packages/astro/src/core/app/middlewares.ts | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 .changeset/gentle-scissors-bow.md 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())) {