refactor: move auth check into pages
This commit is contained in:
parent
dd6b82515e
commit
ddcb14e564
3 changed files with 13 additions and 18 deletions
|
@ -1,18 +1,4 @@
|
|||
import { auth } from '@/auth';
|
||||
|
||||
export default auth((req) => {
|
||||
if (
|
||||
!req.auth &&
|
||||
req.nextUrl.pathname !== '/login' &&
|
||||
process.env.MEETUP_SKIP_LOGIN !== 'true'
|
||||
) {
|
||||
const newUrl = new URL('/login', req.nextUrl.origin);
|
||||
return Response.redirect(newUrl);
|
||||
} else if (req.auth != null && req.nextUrl.pathname === '/') {
|
||||
const newUrl = new URL('/home', req.nextUrl.origin);
|
||||
return Response.redirect(newUrl);
|
||||
}
|
||||
});
|
||||
export { auth as middleware } from '@/auth';
|
||||
|
||||
export const config = {
|
||||
matcher: ['/((?!api|_next/static|_next/image|favicon.ico).*)'],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue