|
1 |
| -import { NextResponse } from "next/server" |
2 | 1 | import createMiddleware from "next-intl/middleware"
|
3 | 2 |
|
4 | 3 | import { routing } from "./src/i18n/routing"
|
5 | 4 |
|
6 |
| -// Create the base middleware |
7 |
| -const intlMiddleware = createMiddleware(routing) |
8 |
| - |
9 |
| -// Wrap it with our debugging middleware |
10 |
| -export default async function middleware(request) { |
11 |
| - // Use console.log for Edge Runtime compatible logging |
12 |
| - console.log("\n🔍 MIDDLEWARE DEBUG START") |
13 |
| - console.log(`📥 Original URL: ${request.url}`) |
14 |
| - console.log(`📥 Original pathname: ${request.nextUrl.pathname}`) |
15 |
| - console.log(`🌐 Default locale: ${routing.defaultLocale}`) |
16 |
| - |
17 |
| - // Skip middleware for static files and API routes |
18 |
| - if ( |
19 |
| - request.nextUrl.pathname.startsWith("/_next") || |
20 |
| - request.nextUrl.pathname.startsWith("/api") || |
21 |
| - request.nextUrl.pathname.includes(".") |
22 |
| - ) { |
23 |
| - console.log("⏭️ Skipping middleware for static/API route") |
24 |
| - return NextResponse.next() |
25 |
| - } |
26 |
| - |
27 |
| - // Call the next-intl middleware for all paths |
28 |
| - const response = await intlMiddleware(request) |
29 |
| - |
30 |
| - // Log the response |
31 |
| - console.log(`📤 Redirect URL: ${response.headers.get("location")}`) |
32 |
| - console.log(`📤 Response status: ${response.status}`) |
33 |
| - console.log( |
34 |
| - `📤 Response headers: ${JSON.stringify(Object.fromEntries(response.headers), null, 2)}` |
35 |
| - ) |
36 |
| - console.log("🔍 MIDDLEWARE DEBUG END\n") |
37 |
| - |
38 |
| - return response |
39 |
| -} |
| 5 | +export default createMiddleware(routing) |
40 | 6 |
|
41 | 7 | // Simplified matcher pattern
|
42 | 8 | export const config = {
|
|
0 commit comments