Skip to content

Commit

Permalink
Merge pull request #260 from depromeet/feature/#255
Browse files Browse the repository at this point in the history
POST 조건 추가
  • Loading branch information
YOOJS1205 authored Feb 12, 2024
2 parents a8dc984 + 33b117b commit 15bcc99
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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);
}
}
}
Expand Down

0 comments on commit 15bcc99

Please sign in to comment.