대민 미들웨어 경유

This commit is contained in:
ljpark
2025-10-02 13:51:48 +09:00
parent 5e3f5e6aa8
commit 7cb4f624ee
8 changed files with 85 additions and 30 deletions
+19 -4
View File
@@ -1,5 +1,11 @@
//8880
import { AUTH_USER_ID, CLAIM_NAME } from "@/src/shared/config";
import { DEV_URL_FO, DEV_URL_WR } from "../config";
import { getCookie } from "@common/components/lib/cookie";
const PROXY_HOST = process.env.NEXT_PUBLIC_PROXY_HOST;
const tokenId = getCookie(AUTH_USER_ID);
const Authorization = getCookie(CLAIM_NAME);
export const fetchType = {
COMMON: "common",
@@ -13,10 +19,13 @@ interface RequestParams {
export const getFetch = async (type: string, url: string) => {
const baseUrl = type === fetchType.FO ? DEV_URL_FO : DEV_URL_WR;
const response = await fetch(baseUrl + url, {
console.log("호출주소 ", PROXY_HOST+baseUrl + url);
const response = await fetch(PROXY_HOST+baseUrl + url, {
method: "GET",
headers: {
accept: "application/json",
[AUTH_USER_ID]: tokenId ?? "",
[CLAIM_NAME]: Authorization ?? "",
},
});
@@ -28,10 +37,12 @@ export const getFetch = async (type: string, url: string) => {
};
export const postFetch = async (url: string, params: RequestParams) => {
const response = await fetch(DEV_URL_WR + url, {
const response = await fetch(PROXY_HOST+DEV_URL_WR + url, {
method: "POST",
headers: {
"Content-Type": "application/json",
[AUTH_USER_ID]: tokenId ?? "",
[CLAIM_NAME]: Authorization ?? "",
},
body: JSON.stringify(params),
});
@@ -43,10 +54,12 @@ export const postFetch = async (url: string, params: RequestParams) => {
};
export const putFetch = async (url: string, params: RequestParams) => {
const response = await fetch(DEV_URL_WR + url, {
const response = await fetch(PROXY_HOST+DEV_URL_WR + url, {
method: "PUT",
headers: {
"Content-Type": "application/json",
[AUTH_USER_ID]: tokenId ?? "",
[CLAIM_NAME]: Authorization ?? "",
},
body: JSON.stringify(params),
});
@@ -58,10 +71,12 @@ export const putFetch = async (url: string, params: RequestParams) => {
};
export const deleteFetch = async (url: string, params: RequestParams) => {
const response = await fetch(DEV_URL_WR + url, {
const response = await fetch(PROXY_HOST+DEV_URL_WR + url, {
method: "DELETE",
headers: {
"Content-Type": "application/json",
[AUTH_USER_ID]: tokenId ?? "",
[CLAIM_NAME]: Authorization ?? "",
},
body: JSON.stringify(params),
});