From bd3848d5ffcb5b99bf04742da41029bda3050d44 Mon Sep 17 00:00:00 2001 From: chpark Date: Thu, 25 Sep 2025 16:57:35 +0900 Subject: [PATCH] =?UTF-8?q?=EC=98=A4=EB=A5=98=EC=98=A4=EB=A3=BD=EB=A3=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/index.html | 2 +- public/js/app.js | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/public/index.html b/public/index.html index 7c25b2f..afb3c85 100644 --- a/public/index.html +++ b/public/index.html @@ -884,7 +884,7 @@ curl -X DELETE http://localhost:5577/api/users/user005 \
- http://localhost:5577 + http://localhost:5577
diff --git a/public/js/app.js b/public/js/app.js index f899390..f24fe31 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -12,6 +12,9 @@ document.addEventListener('DOMContentLoaded', function() { function initializeApp() { hideLoading(); + // 동적으로 현재 서버 주소 설정 + updateBaseUrl(); + // 저장된 토큰 확인 const savedToken = localStorage.getItem('authToken'); if (savedToken) { @@ -25,6 +28,21 @@ function initializeApp() { setupEventListeners(); } +// 현재 접속한 서버 주소로 Base URL 업데이트 +function updateBaseUrl() { + const currentHost = window.location.host; // 현재 호스트:포트 + const currentProtocol = window.location.protocol; // http: 또는 https: + const baseUrl = `${currentProtocol}//${currentHost}`; + + // API 테스터의 Base URL 업데이트 + const baseUrlElement = document.getElementById('baseUrl'); + if (baseUrlElement) { + baseUrlElement.textContent = baseUrl; + } + + console.log('Base URL 설정:', baseUrl); +} + // 이벤트 리스너 설정 function setupEventListeners() { // 로그인 폼 @@ -1222,7 +1240,9 @@ async function sendApiRequest() { return; } - const fullUrl = `http://localhost:5577${url}`; + // 동적으로 현재 서버 주소 사용 + const baseUrl = `${window.location.protocol}//${window.location.host}`; + const fullUrl = `${baseUrl}${url}`; const startTime = Date.now(); try {