0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-16 21:46:22 -05:00

fix(routing): don't check headers for prenredered pages (#12302)

This commit is contained in:
Emanuele Stoppa 2024-10-25 15:16:54 +01:00 committed by GitHub
parent 4e9a3ac0bd
commit 7196c244ea
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Fixes an issue where the origin check middleware run for prendered pages

View file

@ -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())) {