MeetUp/src/middleware.ts
SomeCodecat 97ea28f588
All checks were successful
container-scan / Container Scan (pull_request) Successful in 2m23s
docker-build / docker (pull_request) Successful in 7m35s
fix: correct condition for MEETUP_SKIP_LOGIN environment variable in middleware
2025-05-08 13:21:28 +02:00

16 lines
377 B
TypeScript

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);
}
});
export const config = {
matcher: ['/((?!api|_next/static|_next/image|favicon.ico).*)'],
};