Skip to content

Commit 52b331a

Browse files
committed
feat: 세션 토큰을 URL에서 캡처하여 쿠키에 저장하는 기능 추가 및 관련 설정 업데이트
1 parent 72155f3 commit 52b331a

8 files changed

Lines changed: 24 additions & 4 deletions

File tree

‎apps/pyconkr-2025/src/main.tsx‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Global } from "@emotion/react";
22
import { CenteredPage, CommonContextProvider, ErrorFallback } from "@frontend/common/components";
33
import type { ContextOptions } from "@frontend/common/contexts";
4-
import { registerChunkLoadErrorReloadHandler } from "@frontend/common/utils";
4+
import { captureSessionTokenFromURL, registerChunkLoadErrorReloadHandler } from "@frontend/common/utils";
55
import { ShopContextProvider } from "@frontend/shop/components/common";
66
import { ContextOptions as ShopContextOptions } from "@frontend/shop/contexts";
77
import { CircularProgress, CssBaseline, ThemeProvider } from "@mui/material";
@@ -13,11 +13,11 @@ import { FC, StrictMode, useState } from "react";
1313
import { createRoot } from "react-dom/client";
1414
import { RouterProvider } from "react-router-dom";
1515

16-
import { router } from "./router.tsx";
1716
import { IS_DEBUG_ENV } from "./consts";
1817
import { LOCAL_STORAGE_LANGUAGE_KEY } from "./consts/local_stroage.ts";
1918
import { PyConKRMDXComponents } from "./consts/mdx_components.ts";
2019
import { AppContext, AppContextType } from "./contexts/app_context.tsx";
20+
import { router } from "./router.tsx";
2121
import { globalStyles, muiTheme } from "./styles/globalStyles.ts";
2222

2323
const queryClient = new QueryClient({
@@ -106,5 +106,6 @@ export const MainApp: FC = () => {
106106
};
107107

108108
registerChunkLoadErrorReloadHandler();
109+
captureSessionTokenFromURL(import.meta.env.VITE_PYCONKR_BACKEND_SESSION_COOKIE_NAME);
109110

110111
createRoot(document.getElementById("root")!).render(<MainApp />);

‎apps/pyconkr-2025/vite.config.mts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export default defineConfig(({ mode }) => {
3535
proxy: {
3636
"/v1": proxyOptions,
3737
"/api": proxyOptions,
38+
"/authn": proxyOptions,
3839
},
3940
},
4041
};

‎apps/pyconkr-2026/src/main.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Global } from "@emotion/react";
22
import { CenteredPage, CommonContextProvider, ErrorFallback } from "@frontend/common/components";
33
import type { ContextOptions } from "@frontend/common/contexts";
4-
import { registerChunkLoadErrorReloadHandler } from "@frontend/common/utils";
4+
import { captureSessionTokenFromURL, registerChunkLoadErrorReloadHandler } from "@frontend/common/utils";
55
import { ShopContextProvider } from "@frontend/shop/components/common";
66
import { ContextOptions as ShopContextOptions } from "@frontend/shop/contexts";
77
import { CircularProgress, CssBaseline, ThemeProvider } from "@mui/material";
@@ -107,5 +107,6 @@ export const MainApp: FC = () => {
107107
};
108108

109109
registerChunkLoadErrorReloadHandler();
110+
captureSessionTokenFromURL(import.meta.env.VITE_PYCONKR_BACKEND_SESSION_COOKIE_NAME);
110111

111112
createRoot(document.getElementById("root")!).render(<MainApp />);

‎apps/pyconkr-2026/vite.config.mts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export default defineConfig(({ mode }) => {
3535
proxy: {
3636
"/v1": proxyOptions,
3737
"/api": proxyOptions,
38+
"/authn": proxyOptions,
3839
},
3940
},
4041
};

‎dotenv/.env.development‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
VITE_PYCONKR_FRONTEND_DOMAIN=https://dev.pycon.kr
22
VITE_PYCONKR_BACKEND_API_DOMAIN=https://rest-api-dev.pycon.kr
33
VITE_PYCONKR_BACKEND_CSRF_COOKIE_NAME=DEBUG_PYCONKR_BACKEND_csrftoken
4+
VITE_PYCONKR_BACKEND_SESSION_COOKIE_NAME=DEBUG_PYCONKR_BACKEND_sessionid
45
VITE_PYCONKR_SHOP_IMP_ACCOUNT_ID=imp80859147

‎dotenv/.env.production‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
VITE_PYCONKR_FRONTEND_DOMAIN=https://2025.pycon.kr
22
VITE_PYCONKR_BACKEND_API_DOMAIN=https://rest-api.pycon.kr
33
VITE_PYCONKR_BACKEND_CSRF_COOKIE_NAME=PYCONKR_BACKEND_csrftoken
4+
VITE_PYCONKR_BACKEND_SESSION_COOKIE_NAME=PYCONKR_BACKEND_sessionid
45
VITE_PYCONKR_SHOP_IMP_ACCOUNT_ID=imp96676915

‎packages/common/src/utils/cookie.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,17 @@ export const getCookie = (name: string) => {
1010
});
1111
return cookieValue;
1212
};
13+
14+
export const captureSessionTokenFromURL = (cookieName: string | undefined): void => {
15+
if (!cookieName) return;
16+
17+
const hash = window.location.hash.replace(/^#/, "");
18+
if (!hash) return;
19+
20+
const hashParams = new URLSearchParams(hash);
21+
const token = hashParams.get("session_token");
22+
if (!token) return;
23+
24+
document.cookie = `${cookieName}=${encodeURIComponent(token)}; path=/; SameSite=Lax; Secure; Max-Age=1209600`;
25+
window.history.replaceState({}, "", window.location.pathname + window.location.search);
26+
};

‎packages/common/src/utils/index.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export { buildFlatSiteMap, buildNestedSiteMap, parseCss } from "./api";
22
export { isChunkLoadError, registerChunkLoadErrorReloadHandler, reloadForChunkLoadError } from "./chunk_load_error";
3-
export { getCookie } from "./cookie";
3+
export { captureSessionTokenFromURL, getCookie } from "./cookie";
44
export { getFormValue, isFormValid } from "./form";
55
export { filterPropertiesByLanguageInJsonSchema, filterReadOnlyPropertiesInJsonSchema, filterWritablePropertiesInJsonSchema } from "./json_schema";
66
export { extractQueryParameters } from "./openapi";

0 commit comments

Comments
 (0)