refactor: moving locale definition
This commit is contained in:
@@ -3,6 +3,8 @@ import {getRequestConfig} from 'next-intl/server';
|
||||
|
||||
// Can be imported from a shared config
|
||||
export const locales = ['en', 'hr'];
|
||||
|
||||
export const defaultLocale = 'en';
|
||||
|
||||
export default getRequestConfig(async ({locale}) => {
|
||||
// Validate that the incoming `locale` parameter is valid
|
||||
|
||||
@@ -2,6 +2,7 @@ import NextAuth, { NextAuthConfig } from 'next-auth';
|
||||
import GoogleProvider from 'next-auth/providers/google';
|
||||
import { Session } from 'next-auth';
|
||||
import { AuthenticatedUser } from './types/next-auth';
|
||||
import { defaultLocale } from '../i18n';
|
||||
|
||||
export const authConfig: NextAuthConfig = {
|
||||
callbacks: {
|
||||
@@ -46,7 +47,7 @@ export const authConfig: NextAuthConfig = {
|
||||
strategy: 'jwt'
|
||||
},
|
||||
pages: {
|
||||
signIn: '/en/login',
|
||||
signIn: `/${defaultLocale}/login`,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -6,14 +6,14 @@
|
||||
import { auth, authConfig } from '@/app/lib/auth'
|
||||
import createIntlMiddleware from 'next-intl/middleware';
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import { locales } from '@/app/i18n';
|
||||
import { locales, defaultLocale } from '@/app/i18n';
|
||||
|
||||
const publicPages = ['/terms', '/policy', '/login'];
|
||||
|
||||
const intlMiddleware = createIntlMiddleware({
|
||||
locales,
|
||||
localePrefix: 'as-needed',
|
||||
defaultLocale: 'hr'
|
||||
defaultLocale
|
||||
});
|
||||
|
||||
export default async function middleware(req: NextRequest) {
|
||||
|
||||
Reference in New Issue
Block a user