From 206bbb1f7c9e8777b4037a1501a375fc12bd8f1a Mon Sep 17 00:00:00 2001 From: testusuke Date: Sun, 6 Oct 2024 20:25:21 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=E3=83=9F=E3=83=89=E3=83=AB=E3=82=A6?= =?UTF-8?q?=E3=82=A7=E3=82=A2=E3=81=AE=E3=83=AA=E3=83=80=E3=82=A4=E3=83=AC?= =?UTF-8?q?=E3=82=AF=E3=83=88=E5=87=A6=E7=90=86=E3=82=92=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- middleware.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/middleware.ts b/middleware.ts index 1695f1f..09cc6a5 100644 --- a/middleware.ts +++ b/middleware.ts @@ -14,7 +14,13 @@ export function middleware(request: NextRequest) { // check if next path starts with any of the protected paths or root if (protectedPaths.some(path => request.nextUrl.pathname.startsWith(path)) || request.nextUrl.pathname === '/') { - return NextResponse.redirect(new URL('/login', request.url)); + const subDirectory = process.env.SUB_DIRECTORY + if (subDirectory) { + return NextResponse.redirect(new URL(subDirectory + '/login', request.url)); + } + else { + return NextResponse.redirect(new URL('/login', request.url)); + } } }