Skip to content

Commit

Permalink
fix: ミドルウェアのリダイレクト処理を変更
Browse files Browse the repository at this point in the history
  • Loading branch information
testusuke committed Oct 6, 2024
1 parent e107149 commit 206bbb1
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
}

Expand Down

0 comments on commit 206bbb1

Please sign in to comment.