fix: invalid redirection after jwt expiry

This commit is contained in:
Elias Schneider
2023-02-06 11:15:46 +01:00
parent 4e840ecd29
commit 82f204e8a9
5 changed files with 37 additions and 14 deletions

View File

@@ -105,7 +105,13 @@ export async function middleware(request: NextRequest) {
];
for (const rule of rules) {
if (rule.condition)
return NextResponse.redirect(new URL(rule.path, request.url));
if (rule.condition) {
let { path } = rule;
if (path == "/auth/signIn") {
path = path + "?redirect=" + encodeURIComponent(route);
}
return NextResponse.redirect(new URL(path, request.url));
}
}
}