Next.js Discord

Discord Forum

Combine multiple middlewares (NextAuth & Next-Intl)

Unanswered
Allegheny mound ant posted this in #help-forum
Open in Discord
Avatar
Allegheny mound antOP
I have 2 middlewares, from both NextAuth and Next-intl.

How do I combine these into a single exported middleware?

I tried lots of online solutions, as well as chaining but I couldn't figure it out.

import createMiddleware from 'next-intl/middleware';
import { routing } from './i18n/routing';

export { auth as middleware } from '@/auth';
export default createMiddleware(routing);

export const config = {
  matcher: [
    '/',
    '/(nl|en)/:path*',
    '/((?!api|_next/image|_next/static|favicon.ico.*\\..*).*)',
  ],
};

0 Replies