Some checks failed
Build & Deploy KLZ Cables / 🔍 Prepare Environment (push) Successful in 39s
Build & Deploy KLZ Cables / 🧪 Quality Assurance (push) Successful in 1m33s
Build & Deploy KLZ Cables / 🏗️ Build Gatekeeper (push) Successful in 22s
Build & Deploy KLZ Cables / 🏗️ Build App (push) Successful in 4m47s
Build & Deploy KLZ Cables / 🚀 Deploy (push) Successful in 48s
Build & Deploy KLZ Cables / ⚡ PageSpeed (push) Failing after 3m50s
Build & Deploy KLZ Cables / 🔔 Notifications (push) Successful in 2s
39 lines
1.2 KiB
TypeScript
39 lines
1.2 KiB
TypeScript
import createMiddleware from 'next-intl/middleware';
|
|
import { NextResponse } from 'next/server';
|
|
import type { NextRequest } from 'next/server';
|
|
|
|
// Create the internationalization middleware
|
|
const intlMiddleware = createMiddleware({
|
|
// A list of all locales that are supported
|
|
locales: ['en', 'de'],
|
|
|
|
// Used when no locale matches
|
|
defaultLocale: 'en',
|
|
});
|
|
|
|
// Main middleware that logs all requests
|
|
export default function middleware(request: NextRequest) {
|
|
const startTime = Date.now();
|
|
const { method, url, headers } = request;
|
|
const userAgent = headers.get('user-agent') || 'unknown';
|
|
const referer = headers.get('referer') || 'none';
|
|
const ip = headers.get('x-forwarded-for') || headers.get('x-real-ip') || 'unknown';
|
|
|
|
// Log incoming request
|
|
console.log(`Incoming request: method=${method} host=${headers.get('host')} url=${url}`);
|
|
|
|
try {
|
|
// Apply internationalization middleware
|
|
const response = intlMiddleware(request);
|
|
return response;
|
|
} catch (error) {
|
|
console.error(`Request failed: method=${method} url=${url}`, error);
|
|
throw error;
|
|
}
|
|
}
|
|
|
|
export const config = {
|
|
// Match only internationalized pathnames
|
|
matcher: ['/((?!api|_next|_vercel|health|.*\\..*).*)', '/', '/(de|en)/:path*'],
|
|
};
|