diff --git a/.changeset/unlucky-kids-compete.md b/.changeset/unlucky-kids-compete.md new file mode 100644 index 000000000000..e4b59791ea21 --- /dev/null +++ b/.changeset/unlucky-kids-compete.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fixes a regression where Astro was trying to access `Request.headers` diff --git a/packages/astro/src/core/middleware/noop-middleware.ts b/packages/astro/src/core/middleware/noop-middleware.ts index b141285f699c..c0c9648330d0 100644 --- a/packages/astro/src/core/middleware/noop-middleware.ts +++ b/packages/astro/src/core/middleware/noop-middleware.ts @@ -1,7 +1,8 @@ import type { MiddlewareHandler } from '../../@types/astro.js'; import { NOOP_MIDDLEWARE_HEADER } from '../constants.js'; -export const NOOP_MIDDLEWARE_FN: MiddlewareHandler = (ctx, next) => { - ctx.request.headers.set(NOOP_MIDDLEWARE_HEADER, 'true'); - return next(); +export const NOOP_MIDDLEWARE_FN: MiddlewareHandler = async (_ctx, next) => { + const response = await next(); + response.headers.set(NOOP_MIDDLEWARE_HEADER, 'true'); + return response; };