Skip to content

Commit

Permalink
Skip redirectionio for server actions and components
Browse files Browse the repository at this point in the history
  • Loading branch information
markomitranic committed Nov 1, 2024
1 parent f45f11a commit dcee56f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 4 additions & 0 deletions middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit dcee56f

Please sign in to comment.