Nguyen
Nguyen11mo ago

hoangvu12 – 05-14 Aug 29

I'm using NextJS v13 app router, I have following folder structure. I want to redirect the url from / to /[lng] (with data logic), but for some reason the middleware.ts is not triggered. Here is the code
import { NextRequest, NextResponse } from "next/server";

export const config = {
matcher: "/",
};

export function middleware(req: NextRequest) {
return NextResponse.redirect("/anime");
}
import { NextRequest, NextResponse } from "next/server";

export const config = {
matcher: "/",
};

export function middleware(req: NextRequest) {
return NextResponse.redirect("/anime");
}
2 Replies
Nguyen
Nguyen11mo ago
Fixed by moving middleware the same level as app
reactibot
reactibot11mo ago
This thread hasn’t had any activity in 36 hours, so it’s now locked. Threads are closed automatically after 36 hours. If you have a followup question, you may want to reply to this thread so other members know they're related. https://discord.com/channels/102860784329052160/902647189120118794/1145949538520145950