Chaining or Combining Next.js App Router Middleware #73116
Unanswered
58bits
asked this question in
App Router
Replies: 1 comment 1 reply
-
Hi @58bits Thanks, but you should come here with question next time. |
Beta Was this translation helpful? Give feedback.
1 reply
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