#Middleware issue
30 messages · Page 1 of 1 (latest)
it looks good to me
does this happen on production or development mode?
both
yup
I have almost the same issue, but for me it works fine in development but not in production
try installing the canary version of next.js where have a lot of bugs fixed npm install next@canary
wait I found that home route is not matching
I have the lang in pathname for exemple /en | /fr | /de
Ye I see with next-translate
should I add each to protectedPaths array ?
translation prefixes are not be part of pathname I think
so no
I added a console.log to display the pathname it prints this "/en"
ok..
but its not a neat way
No sorry idk
Can you help me with my code?
export async function middleware(request) {
const cookie = request.cookies.get("token")?.value;
if (request.nextUrl.pathname === "/" && cookie) {
return NextResponse.redirect(new URL("/home", request.url));
}
}
Im not using next-auth, should I use it
Create a ticket I'll answer you there 😄
I don't know if these are good manners, help then ask for help xd
Why do you use url.searchParams.set("callbackUrl", pathname); ?
to keep the callback in the url
ok