⬆️ Upgrade NextJS version

This commit is contained in:
Thomas Camlong
2022-07-06 18:08:03 +02:00
parent 035224b02b
commit be770d282a
4 changed files with 118 additions and 75 deletions

15
src/middleware.ts Normal file
View File

@@ -0,0 +1,15 @@
import { NextFetchEvent, NextRequest, NextResponse } from 'next/server';
export function middleware(req: NextRequest, ev: NextFetchEvent) {
const ok = req.cookies.get('password') === process.env.PASSWORD;
const url = req.nextUrl.clone();
if (
!ok &&
url.pathname !== '/login' &&
process.env.PASSWORD &&
url.pathname !== '/api/configs/tryPassword'
) {
url.pathname = '/login';
}
return NextResponse.rewrite(url);
}