Skip to content

Commit

Permalink
fix(routing): don't access Request headers (#12498)
Browse files Browse the repository at this point in the history
Co-authored-by: ascorbic <[email protected]>
  • Loading branch information
ematipico and ascorbic authored Nov 22, 2024
1 parent 3bed805 commit b140a3f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/unlucky-kids-compete.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Fixes a regression where Astro was trying to access `Request.headers`
7 changes: 4 additions & 3 deletions packages/astro/src/core/middleware/noop-middleware.ts
Original file line number Diff line number Diff line change
@@ -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;
};

0 comments on commit b140a3f

Please sign in to comment.