Too many redirects from localhost
Unanswered
Atlantic mackerel posted this in #help-forum
Atlantic mackerelOP
Hey guys, im trying to add auth and when user login, then redirect to the other url like
And below is my
and also I edit my next.config.mjs but it won't work
how can I fix this problem?
And I wonder how to matcher like this url
http://localhost:3000/clinet/uuid but I don't know exact reason the error Too many redirects from localhost. (I guess it's just infinite looping from middleware.ts)And below is my
middleware.ts codeimport {withAuth} from "next-auth/middleware"
import {NextResponse} from "next/server";
export default withAuth(
function middleware(req) {
if (req.nextauth.token) {
return NextResponse.redirect(
new URL(
`/client/test`,
req.url
));
}
}
)and also I edit my next.config.mjs but it won't work
/** @type {import('next').NextConfig} */
const nextConfig = {
matcher: [
'/',
'/login',
'/client/'
]
};
export default nextConfig;how can I fix this problem?
And I wonder how to matcher like this url
http://localhost:3000/[uuid]