fixed redirection bug
This commit was merged in pull request #10.
This commit is contained in:
+4
-6
@@ -13,13 +13,13 @@ export async function middleware(req, next) {
|
||||
|
||||
const { origin, pathname } = req.nextUrl;
|
||||
|
||||
|
||||
try {
|
||||
console.log("Test path", pathname, origin);
|
||||
// console.log("Test path", pathname, origin);
|
||||
if (token) {
|
||||
// Redirect to the home page if already authenticated
|
||||
NextResponse.redirect(new URL("/"), { status: 201 });
|
||||
next();
|
||||
NextResponse.redirect(new URL(pathname, origin), { status: 302 });
|
||||
// Continue with the request if authenticated
|
||||
return NextResponse.next();
|
||||
}
|
||||
|
||||
if (
|
||||
@@ -43,8 +43,6 @@ export async function middleware(req, next) {
|
||||
// });
|
||||
// }
|
||||
|
||||
// Continue with the request if authenticated
|
||||
return NextResponse.next();
|
||||
} catch (error) {
|
||||
console.error("Error during authentication check:", error);
|
||||
return NextResponse.error();
|
||||
|
||||
Reference in New Issue
Block a user