0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-30 22:03:56 -05:00

fix(routing): don't access Request headers (#12498)

Co-authored-by: ascorbic <213306+ascorbic@users.noreply.github.com>
This commit is contained in:
Emanuele Stoppa 2024-11-22 10:26:48 +00:00 committed by GitHub
parent 3bed8050b9
commit b140a3f6d8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 3 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Fixes a regression where Astro was trying to access `Request.headers`

View file

@ -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;
};