Skip to content

Commit

Permalink
fix(routing): don't check headers for prenredered pages
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico committed Oct 25, 2024
1 parent 90ae100 commit 6c22e61
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/gentle-scissors-bow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Fixes an issue where the origin check middleware run for prendered pages
6 changes: 5 additions & 1 deletion packages/astro/src/core/app/middlewares.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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())) {
Expand Down

0 comments on commit 6c22e61

Please sign in to comment.