Replies: 1 comment 2 replies
-
A request made to a server action will include a next-action header by default which you can check in the middleware const isServerAction = request.headers.get("next-action"); |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary
I'm using server actions in my Next.js app (export function myAction() {} with use server). These server actions are invoked from client components.
I want to include a custom request header (e.g., X-Custom-Header) in every request made from the client to these server actions. The goal is for this header to be accessible in my middleware.ts, where I can process it further.
Is there a standard or recommended way to achieve this without globally overriding fetch? Ideally, I’d like to ensure that all server action calls automatically include this header without requiring modifications to every individual action invocation, but it's still okay if there are ways to achieve this with modifications to the function itself.
Thanks!
Additional information
No response
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions