Skip to content
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
1 change: 0 additions & 1 deletion apps/web/src/apis/Auth/postKakaoAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const usePostKakaoAuth = () => {
setAccessToken(data.accessToken);

toast.success("로그인에 성공했습니다.");

setTimeout(() => {
router.push("/");
}, 100);
Expand Down
15 changes: 1 addition & 14 deletions apps/web/src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import type { NextRequest } from "next/server";
import { NextResponse } from "next/server";

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

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

// 서버 사이드 인증 체크가 활성화된 경우에만 미들웨어 적용
// (RefreshToken은 항상 HTTP-only 쿠키로 관리됨)
const isServerSideAuthEnabled = process.env.NEXT_PUBLIC_COOKIE_LOGIN_ENABLED === "true";
if (!isServerSideAuthEnabled) {
return NextResponse.next();
}

// HTTP-only 쿠키의 refreshToken 확인
const refreshToken = request.cookies.get("refreshToken")?.value;
Comment on lines 14 to 15

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Honor cookie-login flag before enforcing route redirects

The middleware now always enforces refreshToken cookie checks, but this repo still defines NEXT_PUBLIC_COOKIE_LOGIN_ENABLED=false for development (apps/web/.env.development), which is the mode documented for localStorage-based debugging; in that configuration, protected routes like /mentor, /my, and /community will redirect to /login even after client-side login because no HTTP-only cookie is expected. Please keep the flag gate (or remove the false-mode config/docs in the same change) so development auth flow does not break.

Useful? React with 👍 / 👎.


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

if (needLogin && !refreshToken) {
const isCommunityRoute = url.pathname === "/community" || url.pathname.startsWith("/community/");
url.pathname = "/login";
if (isCommunityRoute) {
url.searchParams.set("reason", COMMUNITY_LOGIN_REASON);
} else {
url.searchParams.delete("reason");
}
url.searchParams.delete("reason");
return NextResponse.redirect(url);
}

Expand Down
Loading