Ready for production deployment with Dockerfile and i18n support

This commit is contained in:
2026-04-13 12:57:52 +03:00
parent 8346812507
commit b30376aa1d
32 changed files with 1078 additions and 117 deletions

33
middleware.ts Normal file
View File

@@ -0,0 +1,33 @@
import { NextResponse } from 'next/server';
import type { NextRequest } from 'next/server';
const locales = ['tr', 'en'];
const defaultLocale = 'tr';
export function middleware(request: NextRequest) {
const { pathname } = request.nextUrl;
// Exclude static files, public folder items, API routes, next internals
if (
pathname.startsWith('/_next') ||
pathname.startsWith('/api') ||
pathname.includes('.') ||
pathname === '/favicon.ico'
) {
return NextResponse.next();
}
const pathnameHasLocale = locales.some(
(locale) => pathname.startsWith(`/${locale}/`) || pathname === `/${locale}`
);
if (pathnameHasLocale) return NextResponse.next();
// Redirect if there is no locale
request.nextUrl.pathname = `/${defaultLocale}${pathname}`;
return NextResponse.redirect(request.nextUrl);
}
export const config = {
matcher: ['/((?!_next|api|favicon.ico).*)'],
};