Skip to content

Commit

Permalink
middleware: use config matcher
Browse files Browse the repository at this point in the history
  • Loading branch information
serprex committed Nov 24, 2023
1 parent a93f6cb commit 82d0f87
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions ui/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import type { NextRequest } from 'next/server';

import { NextResponse } from 'next/server';

export default function middleware(req: NextRequest) {
if (
req.nextUrl.pathname !== '/favicon.ico' &&
req.nextUrl.pathname !== '/login' &&
req.nextUrl.pathname !== '/api/login' &&
!req.nextUrl.pathname.startsWith('/images/') &&
!req.nextUrl.pathname.startsWith('/_next/static/') &&
req.nextUrl.pathname !== '/api/logout' &&
process.env.PEERDB_PASSWORD &&
req.cookies.get('auth')?.value !== process.env.PEERDB_PASSWORD
) {
Expand All @@ -17,3 +14,10 @@ export default function middleware(req: NextRequest) {
}
return NextResponse.next();
}

export const config = {
matcher: [
// Match everything other than static assets
'/((?!_next/static/|images/|favicon.ico$).*)',
],
};

0 comments on commit 82d0f87

Please sign in to comment.