Skip to content

Commit

Permalink
fix: avoid double-handling for route
Browse files Browse the repository at this point in the history
  • Loading branch information
bholmesdev committed May 7, 2024
1 parent 4ce722b commit b6bc281
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/astro/src/actions/runtime/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ export type Locals = {

export const onRequest = defineMiddleware(async (context, next) => {
const locals = context.locals as Locals;
const { request } = context;
const { request, url } = context;
const contentType = request.headers.get('Content-Type');

// Avoid double-handling with middleware when calling actions directly.
if (url.pathname.startsWith('/_actions')) return nextWithLocalsStub(next, locals);

if (!contentType || !hasContentType(contentType, formContentTypes))
return nextWithLocalsStub(next, locals);

Expand Down

0 comments on commit b6bc281

Please sign in to comment.