fixed redirection bug

This commit was merged in pull request #10.
This commit is contained in:
2023-10-22 23:08:34 -07:00
parent f67d33396e
commit 1ebb8d61f1
7 changed files with 20 additions and 104 deletions
+4 -6
View File
@@ -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();