Hi
I’m developing Next.js 14 application. Currently I have a middleware which support internationalization (copied from here).
import { NextResponse } from “next/server”;
const locales = [“en-US”];
export const middleware = (request) => {
const { pathname } = request.nextUrl;
const hasLocale = locales.some(
(locale) => pathname.startsWith(/${locale}/
) || pathname ===/${locale}
,
);
if (hasLocale) {
return;
}
request.nextUrl.pathname =/en-US${pathname}
;
return NextResponse.redirect(request.nextUrl);
};export const config = {
matcher: [
// Skip all internal paths (_next)
“/((?!_next).*)”,
],
};
Do you have any idea of how to combine withMiddlewareAuthRequired
into the existing middleware?