refactor: 'SITE_ID' 환경변수 쿠키로 수정

This commit is contained in:
2025-06-30 13:23:29 +09:00
parent 0e9d865f44
commit 9a38ce33c0
6 changed files with 15 additions and 10 deletions
@@ -4,7 +4,6 @@ import {
CLAIM_NAME,
REFRESH_TOKEN,
SERVER_API_URL,
SITE_ID,
} from "@/shared/config";
import { cookies } from "next/headers";
import { NextResponse } from "next/server";
@@ -15,9 +14,10 @@ async function handler(
method: "GET" | "POST" | "PUT" | "DELETE",
) {
const cookieStore = await cookies();
const siteId = cookieStore.get("site-id-key")?.value ?? "";
const headers: Record<string, string> = {
"Content-Type": "application/json",
"X-Site-Id": SITE_ID,
"X-Site-Id": siteId,
};
let body = {};
const isRefreshHandler = params.url.includes("refresh");
@@ -4,10 +4,11 @@ import { useEffect } from "react";
import { usePathname, useRouter } from "next/navigation";
import { MenuAuthorityApi } from "@/entities/menu-authority/@x/menu";
import { getCookie, useAlertStore, useMenuStore } from "@/shared/lib";
import { SITE_ID } from "@/shared/config";
import { MenuApi } from "../api/menu-service";
import { getCurrentMenu } from "./utils";
const siteId = getCookie("site-id-key") ?? "";
const MenuWrapper = ({ children }: { children: React.ReactNode }) => {
const router = useRouter();
const pathname = usePathname();
@@ -17,7 +18,7 @@ const MenuWrapper = ({ children }: { children: React.ReactNode }) => {
useMenuStore((state) => state);
const getCurrentMenuInfo = async () => {
const menuRoles = await MenuApi.getMenuRoles(SITE_ID);
const menuRoles = await MenuApi.getMenuRoles(siteId);
if (!menuRoles) return;
return getCurrentMenu(menuRoles, pathname ?? "");
};
@@ -1,8 +1,10 @@
import { Client } from "@common/network";
import { BASE_URL } from "../config/api";
import { SITE_ID } from "../config/env";
import { getCookie } from "../lib";
const siteId = getCookie("site-id-key") ?? "";
export const client = Client.getInstance({
baseURL: BASE_URL,
siteId: SITE_ID,
siteId,
});
@@ -2,7 +2,6 @@ export const PORT = process.env.NEXT_PUBLIC_PORT || "13000";
export const PROXY_HOST =
process.env.NEXT_PUBLIC_PROXY_HOST || `http://localhost:${PORT}`;
export const SERVER_API_URL = process.env.NEXT_PUBLIC_SERVER_API_URL;
export const SITE_ID = process.env.NEXT_PUBLIC_SITE_ID || "CS";
export const CLAIM_NAME = process.env.NEXT_PUBLIC_CLAIM_NAME || "Authorization";
export const ACCESS_TOKEN =
process.env.NEXT_PUBLIC_ACCESS_TOKEN || "access-token";
+3
View File
@@ -1,6 +1,9 @@
import { Client } from "@common/network";
import { BASE_URL } from "../config/api";
import { SITE_ID } from "../config/env";
import { setCookie } from "../lib";
setCookie("site-id-key", SITE_ID);
export const client = Client.getInstance({
baseURL: BASE_URL,
@@ -3,7 +3,6 @@
import { useState, useEffect, useRef } from "react";
import { useQuery } from "@tanstack/react-query";
import { ChevronRight } from "lucide-react";
import { getConfig } from "@common/config";
import { ENDPOINT } from "../../config";
import { cn, setCookie } from "../../lib";
import { getMenuList, type MenuItem } from "../../api";
@@ -24,8 +23,9 @@ import {
CollapsibleTrigger,
} from "../collapsible";
import { getParentIds } from "./lib";
import { getCookie } from "../../lib";
const { SITE_ID } = getConfig();
const siteId = getCookie("site-id-key") ?? "";
export function LNB({
viewOnly,
@@ -38,7 +38,7 @@ export function LNB({
}) {
const { data: menuList } = useQuery({
queryKey: [ENDPOINT.CMS_SERVICE.MENU_ROLES],
queryFn: () => getMenuList(SITE_ID ?? ""),
queryFn: () => getMenuList(siteId),
enabled: !viewOnly,
});