구조: admin 을 backend/frontend 로 가른다
admin/ 이 프론트 파일만 널려 있는 폴더였다. :9801 을 띄우는 코드도 solution/backend 안에 얹혀 있어서, 폴더만 봐서는 admin 에 백엔드가 있다는 걸 몰랐다. admin/backend/ main.py · app.py (:9801 진입점. 도메인 코드는 PYTHONPATH 로 solution/backend) admin/frontend/ 운영 화면 패키지 이름도 폴더에 맞췄다: @o2o/front → @o2o/frontend. 이미지 빌드 컨텍스트를 레포 루트로 올렸다 — 진입점(admin/)과 도메인 코드(solution/)가 한 이미지에 들어와야 한다. 루트 .dockerignore 로 프론트·문서·시크릿을 잘라냈다. ★ 실측으로 잡은 것: 패키지명을 바꾸면서 compose 의 `-w @o2o/front` 를 안 고쳐 web 컨테이너가 `No workspaces found` 로 재기동 루프에 빠져 있었다. 주석은 짧게 줄였다. 검증: lint·build 6개 전부 0. 컨테이너 5개 엔드포인트(9800·9801·3000·3002·80) 전부 200. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019uYhHQdssRubirPirrdJJC
This commit is contained in:
1 parent
cabcdeaacc
commit
374a3a4a6e
24 files changed
+110
-111
No files matched your search
@@ -0,0 +1,57 @@
|
||||
import {QueryClientProvider} from '@tanstack/react-query';
|
||||
import {useEffect, type ReactNode} from 'react';
|
||||
import {Toaster} from 'sonner';
|
||||
import {getAccessToken, me} from '@/api';
|
||||
import {queryClient} from '@/lib/query-client';
|
||||
import {toAuthUser, useAuthStore} from '@/stores/auth';
|
||||
|
||||
/**
|
||||
* 저장된 액세스 토큰으로 세션을 복구한다.
|
||||
*
|
||||
* ★ 사장님 앱과 결정적으로 다른 점: **여기서는 실패가 곧 차단이다.**
|
||||
* 빌더는 로그인 없이도 돌아야 해서 인증 실패를 삼키지만(solution/frontend/app/provider.tsx),
|
||||
* 내부 운영 화면은 전부 RequireAuth 뒤에 있다. 두 정책을 한 앱에 두면 실수가 늘
|
||||
* 느슨한 쪽으로 나기 때문에 앱을 갈랐다.
|
||||
*/
|
||||
function useRestoreSession() {
|
||||
const setUser = useAuthStore((s) => s.setUser);
|
||||
const finishRestore = useAuthStore((s) => s.finishRestore);
|
||||
|
||||
useEffect(() => {
|
||||
let alive = true;
|
||||
if (!getAccessToken()) {
|
||||
finishRestore();
|
||||
return;
|
||||
}
|
||||
void me()
|
||||
.then((res) => {
|
||||
if (!alive || res.result?.success === false) return;
|
||||
// RemoveNoneResponse 라 신원 필드가 통째로 빠져 올 수 있다 — 반쪽짜리 사용자를 세우지 않는다.
|
||||
if (!res.user_id || !res.id) return;
|
||||
setUser(toAuthUser(res));
|
||||
})
|
||||
.catch(() => {
|
||||
/* 토큰이 죽었으면 비로그인 상태로 떨어뜨린다. RequireAuth 가 로그인으로 보낸다. */
|
||||
})
|
||||
.finally(() => {
|
||||
if (alive) finishRestore();
|
||||
});
|
||||
return () => {
|
||||
alive = false;
|
||||
};
|
||||
}, [setUser, finishRestore]);
|
||||
}
|
||||
|
||||
function SessionGate({children}: {children: ReactNode}) {
|
||||
useRestoreSession();
|
||||
return <>{children}</>;
|
||||
}
|
||||
|
||||
export function Providers({children}: {children: ReactNode}) {
|
||||
return (
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<SessionGate>{children}</SessionGate>
|
||||
<Toaster richColors position="top-center" expand visibleToasts={9} />
|
||||
</QueryClientProvider>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user