configured localization
This commit is contained in:
@@ -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));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user