Skip to content

Commit 01e80f9

Browse files
SOIVclaude
andcommitted
fix(web): 딥 링크 redirect 버그 수정
기존: #login 상태에서 URL을 #admin으로 변경 후 로그인 시 홈으로 이동 원인: redirectAfterLogin이 마운트 시점 hash 기준으로만 초기화되어 이후 hash 변경이 반영되지 않음 수정: hashchange 핸들러에서 비인증 상태 + 앱 route 진입 시 redirectAfterLogin을 함께 갱신 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 5739aec commit 01e80f9

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

apps/web/src/main.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,15 @@ function App({ installMode }: { installMode: InstallMode }) {
179179
const [route, setRoute] = useState<RouteKey>(() => getRouteFromHash(window.location.hash));
180180

181181
useEffect(() => {
182-
const handleHashChange = () => setRoute(getRouteFromHash(window.location.hash));
182+
const handleHashChange = () => {
183+
const next = getRouteFromHash(window.location.hash);
184+
setRoute(next);
185+
// 비인증 상태에서 app route로 hash 변경 시 redirect 대상 갱신
186+
const appRoutes: RouteKey[] = ["home", "marketplace", "admin"];
187+
if (sessionStorage.getItem(SS.auth) !== "true" && (appRoutes as string[]).includes(next)) {
188+
setRedirectAfterLogin(next);
189+
}
190+
};
183191
window.addEventListener("hashchange", handleHashChange);
184192
return () => window.removeEventListener("hashchange", handleHashChange);
185193
}, []);

0 commit comments

Comments
 (0)