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

애플 로그인 시 auth 페이지에 머물도록 수정 #263

Merged
merged 1 commit into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
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
3 changes: 1 addition & 2 deletions src/app/auth/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export default function Page() {
console.log(typeof window !== 'undefined' && window.location.href);
export default async function Page() {
return <></>;
}
16 changes: 16 additions & 0 deletions src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,22 @@ export async function middleware(request: NextRequest) {
: NextResponse.redirect(url);
}
}

if (request.nextUrl.pathname === '/auth' && provider === 'apple') {
// 이미 리다이렉트된 요청인지 확인
if (request.nextUrl.searchParams.has('redirected')) {
// 이미 리다이렉트된 경우, 추가 리다이렉트를 수행하지 않음
return NextResponse.next();
} else {
// 쿼리 파라미터를 포함한 완전한 URL 구성
const redirectUrl = request.nextUrl.clone();
redirectUrl.searchParams.set('type', 'apple');
redirectUrl.searchParams.set('redirected', 'true'); // 리다이렉트 플래그 설정

// 클라이언트에게 리다이렉트 요청
return NextResponse.redirect(redirectUrl, 303);
}
}
}

export const config = {
Expand Down
Loading