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:
parent
3bed8050b9
commit
b140a3f6d8
2 changed files with 9 additions and 3 deletions
5
.changeset/unlucky-kids-compete.md
Normal file
5
.changeset/unlucky-kids-compete.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'astro': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fixes a regression where Astro was trying to access `Request.headers`
|
|
@ -1,7 +1,8 @@
|
||||||
import type { MiddlewareHandler } from '../../@types/astro.js';
|
import type { MiddlewareHandler } from '../../@types/astro.js';
|
||||||
import { NOOP_MIDDLEWARE_HEADER } from '../constants.js';
|
import { NOOP_MIDDLEWARE_HEADER } from '../constants.js';
|
||||||
|
|
||||||
export const NOOP_MIDDLEWARE_FN: MiddlewareHandler = (ctx, next) => {
|
export const NOOP_MIDDLEWARE_FN: MiddlewareHandler = async (_ctx, next) => {
|
||||||
ctx.request.headers.set(NOOP_MIDDLEWARE_HEADER, 'true');
|
const response = await next();
|
||||||
return next();
|
response.headers.set(NOOP_MIDDLEWARE_HEADER, 'true');
|
||||||
|
return response;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue