Routing middleware
Middleware runs before the cache and can rewrite, redirect or add headers.
export default function middleware(request: Request) {
const country = request.headers.get('x-ridgeline-country');
if (country === 'NL') return Response.redirect(new URL('/nl', request.url));
}
export const config = { matcher: ['/((?!_next|api).*)'] };Updated
Was this page helpful?