fix: update middleware to redirect authenticated users to home
Automatically redirectis authenticated users from root path ('/') to the '/home' page.
This commit is contained in:
parent
3b75166971
commit
220505bcff
1 changed files with 3 additions and 0 deletions
|
@ -8,6 +8,9 @@ export default auth((req) => {
|
||||||
) {
|
) {
|
||||||
const newUrl = new URL('/login', req.nextUrl.origin);
|
const newUrl = new URL('/login', req.nextUrl.origin);
|
||||||
return Response.redirect(newUrl);
|
return Response.redirect(newUrl);
|
||||||
|
} else if (req.auth != null && req.nextUrl.pathname === '/') {
|
||||||
|
const newUrl = new URL('/home', req.nextUrl.origin);
|
||||||
|
return Response.redirect(newUrl);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue