Hello there i have one issue in the next js 13 can u please help on that issue ?
Unanswered
Munchkin posted this in #help-forum
MunchkinOP
Hello there i have issue in the routing path in the next js where i want to redirect a link from/agenda to /student agneda is the franch key word and student is english how can do in he next 13 code
10 Replies
MunchkinOP
thank
I have want to redirect from SMS message in next where user got the URL from hise message he is redirect to next js application page
sms URL is this http://localhost:3000/agenda in franch langauge over application file route is http://localhost:3000/student in english how i can redirect on that page of student without redirecting on the agenda in next js 13 ?
I have want to redirect from SMS message in next where user got the URL from hise message he is redirect to next js application page
sms URL is this http://localhost:3000/agenda in franch langauge over application file route is http://localhost:3000/student in english how i can redirect on that page of student without redirecting on the agenda in next js 13 ?
MunchkinOP
please give the solution of upper issue
Komondor
you can do this in middleware
// middleware.ts
import { NextRequest, NextResponse } from 'next/server';
export async function middleware(request: NextRequest) {
const response = NextResponse.next();
const { pathname } = request.nextUrl;
if (pathname === '/agenda') {
return NextResponse.redirect('/student');
}
}MunchkinOP
But it next js 13 where i not create any middleware there
if i create then it work for me ?
if i create then it work for me ?
I work with HOC where i check the userAuthentication
MunchkinOP
please check @Komondor can i create the middleware inside the SRC only or any where ?
"Use the file middleware.ts (or .js) in the root of your project to define Middleware. For example, at the same level as pages or app, or inside src if applicable."
MunchkinOP
Thanks its done