refactor: move auth check into pages

This commit is contained in:
Dominik 2025-05-12 21:17:46 +02:00 committed by Dominik
parent dd6b82515e
commit ddcb14e564
3 changed files with 13 additions and 18 deletions

View file

@ -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).*)'],