dm: GATEWAY_URL 추가

This commit is contained in:
2026-01-15 15:51:08 +09:00
parent 21b043cbae
commit 4e27466f00
6 changed files with 31 additions and 23 deletions
+19 -6
View File
@@ -1,23 +1,33 @@
//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 tokenId = getCookie(AUTH_USER_ID);
const Authorization = getCookie(CLAIM_NAME);
export const fetchType = {
COMMON: "common",
WR: "wr",
FO:'fo'
FO: "fo",
SN: "sn"
};
const API_VERSION = "/api/v1"
const servers = {
common: "",
local: "",
fo: "/operation-service" + API_VERSION,
wr: "/reuse-service" + API_VERSION,
sn: "/sewerage-service" + API_VERSION,
}
interface RequestParams {
[key: string]: unknown;
}
export const getFetch = async (type: string, url: string) => {
const baseUrl = type === fetchType.FO ? DEV_URL_FO : DEV_URL_WR;
const baseUrl = servers[type];
const response = await fetch(baseUrl + url, {
method: "GET",
headers: {
@@ -35,7 +45,8 @@ 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 baseUrl = servers[fetchType.WR];
const response = await fetch(baseUrl + url, {
method: "POST",
headers: {
"Content-Type": "application/json",
@@ -52,7 +63,8 @@ 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 baseUrl = servers[fetchType.WR];
const response = await fetch(baseUrl + url, {
method: "PUT",
headers: {
"Content-Type": "application/json",
@@ -69,7 +81,8 @@ 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 baseUrl = servers[fetchType.WR];
const response = await fetch(baseUrl + url, {
method: "DELETE",
headers: {
"Content-Type": "application/json",