Files
frontend/packages/common/network/utils.ts
T

21 lines
937 B
TypeScript

export function getAuthLoginRedirectUrl(): string {
return (
process.env.NEXT_PUBLIC_AUTH_LOGIN_REDIRECT_URL ||
process.env.NEXT_PUBLIC_CM_LOGIN_PAGE_URL ||
"/auth/login"
);
}
export function isAtLoginRedirectUrl(loginRedirectUrl: string): boolean {
if (typeof window === "undefined") return false; // 서버 환경에서는 현재 브라우저 URL을 알 수 없으므로 false 반환
try {
const target = new URL(loginRedirectUrl, window.location.href); // 상대경로/절대경로 모두 현재 주소 기준의 완전한 URL로 변환
return (
target.origin === window.location.origin && // 도메인(프로토콜 + 호스트 + 포트)이 같은지 확인
target.pathname === window.location.pathname // 현재 페이지 경로가 로그인 이동 경로와 같은지 확인
);
} catch {
return false; // 잘못된 URL 문자열이면 비교할 수 없으므로 false 반환
}
}