Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POST 조건 추가 #260

Merged
merged 1 commit into from
Feb 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading