Skip to content

Commit 44e467a

Browse files
authored
fix: auth 리디렉션 정책 단순화 및 로그인 후 메인 이동 통일 (#476)
* fix(web): simplify auth redirects and route login success to home * fix(web): restore kakao signup redirect and protect community routes * fix(web): rollback postAppleAuth to main behavior
1 parent ed7c58e commit 44e467a

File tree

2 files changed

+1
-15
lines changed

2 files changed

+1
-15
lines changed

apps/web/src/apis/Auth/postKakaoAuth.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ const usePostKakaoAuth = () => {
2222
setAccessToken(data.accessToken);
2323

2424
toast.success("로그인에 성공했습니다.");
25-
2625
setTimeout(() => {
2726
router.push("/");
2827
}, 100);

apps/web/src/middleware.ts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import type { NextRequest } from "next/server";
22
import { NextResponse } from "next/server";
33

44
const loginNeedPages = ["/mentor", "/my", "/community"]; // 로그인 필요페이지
5-
const COMMUNITY_LOGIN_REASON = "community-members-only";
65

76
export function middleware(request: NextRequest) {
87
const url = request.nextUrl.clone();
@@ -12,13 +11,6 @@ export function middleware(request: NextRequest) {
1211
// return NextResponse.next();
1312
// }
1413

15-
// 서버 사이드 인증 체크가 활성화된 경우에만 미들웨어 적용
16-
// (RefreshToken은 항상 HTTP-only 쿠키로 관리됨)
17-
const isServerSideAuthEnabled = process.env.NEXT_PUBLIC_COOKIE_LOGIN_ENABLED === "true";
18-
if (!isServerSideAuthEnabled) {
19-
return NextResponse.next();
20-
}
21-
2214
// HTTP-only 쿠키의 refreshToken 확인
2315
const refreshToken = request.cookies.get("refreshToken")?.value;
2416

@@ -28,13 +20,8 @@ export function middleware(request: NextRequest) {
2820
});
2921

3022
if (needLogin && !refreshToken) {
31-
const isCommunityRoute = url.pathname === "/community" || url.pathname.startsWith("/community/");
3223
url.pathname = "/login";
33-
if (isCommunityRoute) {
34-
url.searchParams.set("reason", COMMUNITY_LOGIN_REASON);
35-
} else {
36-
url.searchParams.delete("reason");
37-
}
24+
url.searchParams.delete("reason");
3825
return NextResponse.redirect(url);
3926
}
4027

0 commit comments

Comments
 (0)