configured localization

This commit is contained in:
2024-02-16 15:46:48 +01:00
parent fdea05d4e3
commit 64bd026d46
5 changed files with 53 additions and 6 deletions

View File

@@ -4,10 +4,26 @@
*/
import { auth } from '@/app/lib/auth'
import createIntlMiddleware from 'next-intl/middleware';
const locales = ['en', 'de'];
const publicPages = ['/', '/login'];
export default auth; // middleware will call NextAuth's `auth` method, which will in turn call) see `auth.ts`
const intlMiddleware = createIntlMiddleware({
locales,
localePrefix: 'as-needed',
defaultLocale: 'hr'
});
export const config = {
// midleware will NOT be called for paths: ['/api/auth/*', '/_next/static/*', '/_next/image*']
matcher: ['/((?!api|policy|terms|_next/static|_next/image|.*\\.png$|.*\\.webm$).*)'],
};
// midleware will NOT be called for paths: '/api/auth/*', '/_next/static/*', '/_next/image*', static files and public pages
matcher: [
'/((?!api|_next/static|_next/image|.*\\.png$|.*\\.webm$|(en|hr)/(!?policy|terms|login)).*)'
],
};
// middleware will call NextAuth's `auth` method, which will in turn call) see `auth.ts`
export default auth((req) => {
// call the internalization middleware
return(intlMiddleware(req));
});