Skip to content

Commit dcee56f

Browse files
committed
Skip redirectionio for server actions and components
1 parent f45f11a commit dcee56f

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

middleware.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ export const createRedirectionIoMiddleware = (config) => {
5353
if (!useFetch) {
5454
return response ?? next();
5555
}
56+
// Disable for server-actions and components.
57+
if (request.headers.get('Next-Action')?.length || request.headers.get('Accept') === "text/x-component") {
58+
return response ?? next();
59+
}
60+
5661
const fetchResponse = await fetch(request, {
5762
redirect: "manual",
5863
cache: "no-store",

middleware.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ export const createRedirectionIoMiddleware = (config: CreateMiddlewareConfig): M
8080
if (!useFetch) {
8181
return response ?? next();
8282
}
83+
// Disable for server-actions and components.
84+
if (request.headers.get('Next-Action')?.length || request.headers.get('Accept') === "text/x-component") {
85+
return response ?? next();
86+
}
8387

8488
const fetchResponse = await fetch(request, {
8589
redirect: "manual",

0 commit comments

Comments
 (0)