From c4abdbed3e4d229022e02120ebd43fa4b4133dd8 Mon Sep 17 00:00:00 2001 From: gahusb Date: Thu, 26 Feb 2026 00:38:07 +0900 Subject: [PATCH] =?UTF-8?q?portfolio=20api=20=EC=98=A4=EB=A5=98=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api.js | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/src/api.js b/src/api.js index 8cca773..ccda8be 100644 --- a/src/api.js +++ b/src/api.js @@ -1,25 +1,7 @@ // src/api.js -const API_BASE = import.meta.env.VITE_API_BASE || ""; - -const toApiUrl = (path) => { - if (!API_BASE) return path; - - try { - const base = new URL(API_BASE, window.location.origin); - // Ensure base pathname ends with '/' if it's not the root or if likely intended as a directory - if (!base.pathname.endsWith('/')) { - base.pathname += '/'; - } - - // Remove leading slash from path to avoid double slashes when joining - const cleanPath = path.startsWith('/') ? path.slice(1) : path; - - return new URL(cleanPath, base).toString(); - } catch (error) { - console.error("Invalid VITE_API_BASE configuration:", error); - return path; - } -}; +// 프론트와 API가 동일 도메인(nginx 프록시)이므로 항상 상대 경로 사용. +// 절대 URL(VITE_API_BASE)은 Mixed Content를 유발하므로 사용하지 않음. +const toApiUrl = (path) => path; export async function apiGet(path) { const res = await fetch(toApiUrl(path), {