diff --git a/middleware.js b/middleware.js index dd50300..3b66f66 100644 --- a/middleware.js +++ b/middleware.js @@ -53,6 +53,11 @@ export const createRedirectionIoMiddleware = (config) => { if (!useFetch) { return response ?? next(); } + // Disable for server-actions and components. + if (request.headers.get('Next-Action')?.length || request.headers.get('Accept') === "text/x-component") { + return response ?? next(); + } + const fetchResponse = await fetch(request, { redirect: "manual", cache: "no-store", diff --git a/middleware.ts b/middleware.ts index b168236..b712529 100644 --- a/middleware.ts +++ b/middleware.ts @@ -80,6 +80,10 @@ export const createRedirectionIoMiddleware = (config: CreateMiddlewareConfig): M if (!useFetch) { return response ?? next(); } + // Disable for server-actions and components. + if (request.headers.get('Next-Action')?.length || request.headers.get('Accept') === "text/x-component") { + return response ?? next(); + } const fetchResponse = await fetch(request, { redirect: "manual",