Chaining or Combining Next.js App Router Middleware #73116
Unanswered
58bits
asked this question in
App Router
Replies: 2 comments 1 reply
-
Hi @58bits Thanks, but you should come here with question next time. |
Beta Was this translation helpful? Give feedback.
1 reply
-
Hi, you are setting request headers via request.headers.set function, and it works fine, and u can receive it later in server components, for example, if u need to set nonce for a script |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi all - we've published (and updated) our middleware chaining strategy...
https://www.58bits.com/blog/chaining-or-combining-nextjs-middleware
Our
chainMiddleware.ts
helper function now looks like this...Our
types.ts
definition looks like this...Here are a couple of example plugins (a larger collection including withNonce, withAuth, withi18n, are in the blog post)...
withPrefersColorScheme.ts
withCSP.ts
...etc.
Which can all be used in
middleware.ts
like this..Hope this helps....
Beta Was this translation helpful? Give feedback.
All reactions