[common/components] feat: raw fetch 헤더에 토큰 주입

This commit is contained in:
2026-07-20 18:35:14 +09:00
parent 2f0448a98e
commit 196d31a084
4 changed files with 37 additions and 18 deletions
@@ -0,0 +1,22 @@
import Cookies from "js-cookie";
import { getConfig } from "@common/config";
export function getAuthHeaders(): HeadersInit {
const { CLAIM_NAME, AUTH_USER_ID } = getConfig();
if (!CLAIM_NAME || !AUTH_USER_ID) {
throw new Error("Required environment variables are not set");
}
const headers: Record<string, string> = {
"Content-Type": "application/json",
};
const token = Cookies.get(CLAIM_NAME);
const userId = Cookies.get(AUTH_USER_ID);
if (token) headers[CLAIM_NAME] = token;
if (userId) headers[AUTH_USER_ID] = userId;
return headers;
}