From 33b117b61d3e3650327dc7cf3ba51ce49e29db3f Mon Sep 17 00:00:00 2001 From: YOOJS1205 Date: Mon, 12 Feb 2024 16:57:25 +0900 Subject: [PATCH] =?UTF-8?q?POST=20=EC=A1=B0=EA=B1=B4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/middleware.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/middleware.ts b/src/middleware.ts index 3ed5c270..88a0d8e6 100644 --- a/src/middleware.ts +++ b/src/middleware.ts @@ -8,9 +8,9 @@ export async function middleware(request: NextRequest) { // NOTE: 메인 페이지 진입 시 토큰이 존재하지 않으면 로그인 페이지로 리다이렉트 if (request.nextUrl.pathname === '/') { - // if (request.method === 'POST') { - // return NextResponse.redirect(new URL('/', request.url), 303); - // } + if (request.method === 'POST') { + return NextResponse.redirect(new URL('/', request.url), 303); + } const cookieAccessToken = request.cookies.get('accessToken'); const cookieRefreshToken = request.cookies.get('refreshToken'); @@ -84,7 +84,9 @@ export async function middleware(request: NextRequest) { // NOTE: 토큰 발급 실패 시 로그인 페이지로 이동 url.pathname = '/login'; url.search = ''; - return NextResponse.redirect(url); + return request.method === 'POST' + ? NextResponse.redirect(url, 303) + : NextResponse.redirect(url); } } }