From a966b4a6abe146bbf9f9cbd4a83839cee62d3017 Mon Sep 17 00:00:00 2001 From: backuppc Date: Mon, 3 Nov 2025 11:02:28 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=ED=8F=AC=ED=8A=B8=20=EC=B6=A9=EB=8F=8C?= =?UTF-8?q?=20=EB=B0=A9=EC=A7=80=20-=20=EC=9E=90=EB=8F=99=20=ED=8F=AC?= =?UTF-8?q?=ED=8A=B8=20=ED=83=90=EC=83=89=20=EB=B0=8F=20=EC=83=81=EB=8C=80?= =?UTF-8?q?=20=EA=B2=BD=EB=A1=9C=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 백엔드 변경사항: - fMain.cs: 포트 7979~8000 범위에서 자동 탐색 및 fallback 기능 추가 - 성공한 포트를 Pub.WebServiceURL에 자동 저장 - 포트 충돌 시 자동으로 다음 포트 시도 프론트엔드 변경사항: - login.html: 하드코딩 URL 3곳을 상대 경로로 변경 - Common.html: 하드코딩 URL 4곳을 상대 경로로 변경 - DashBoard/index.html: 하드코딩 URL 10곳을 상대 경로로 변경 효과: - 포트 충돌 시 사용자 개입 없이 자동 해결 - 포트 변경에 무관하게 프론트엔드 자동 동작 - 다양한 환경에서 안정적인 서비스 제공 🤖 Generated with Claude Code (https://claude.com/claude-code) Co-Authored-By: Claude --- Project/Web/wwwroot/Common.html | 20 ++++----- Project/Web/wwwroot/DashBoard/index.html | 20 ++++----- Project/Web/wwwroot/login.html | 6 +-- Project/fMain.cs | 53 +++++++++++++++++------- 4 files changed, 62 insertions(+), 37 deletions(-) diff --git a/Project/Web/wwwroot/Common.html b/Project/Web/wwwroot/Common.html index f5550aa..bdcdf3e 100644 --- a/Project/Web/wwwroot/Common.html +++ b/Project/Web/wwwroot/Common.html @@ -448,8 +448,8 @@ // 코드그룹 목록 로드 function loadGroups() { showLoading(); - - fetch('http://127.0.0.1:7979/Common/GetGroups') + + fetch('/Common/GetGroups') .then(response => response.json()) .then(data => { groupData = data || []; @@ -517,8 +517,8 @@ // 특정 그룹의 데이터 로드 function loadDataByGroup(grp) { showLoading(); - - let url = 'http://127.0.0.1:7979/Common/GetList'; + + let url = '/Common/GetList'; if (grp) { url += '?grp=' + encodeURIComponent(grp); } @@ -642,10 +642,10 @@ // 삭제 실행 function confirmDelete() { if (!deleteTargetIdx) return; - + showLoading(); - - fetch('http://127.0.0.1:7979/Common/Delete', { + + fetch('/Common/Delete', { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -704,10 +704,10 @@ svalue2: document.getElementById('editSvalue2').value, memo: document.getElementById('editMemo').value }; - + showLoading(); - - fetch('http://127.0.0.1:7979/Common/Save', { + + fetch('/Common/Save', { method: 'POST', headers: { 'Content-Type': 'application/json', diff --git a/Project/Web/wwwroot/DashBoard/index.html b/Project/Web/wwwroot/DashBoard/index.html index 89d3704..384af01 100644 --- a/Project/Web/wwwroot/DashBoard/index.html +++ b/Project/Web/wwwroot/DashBoard/index.html @@ -684,7 +684,7 @@ // 휴가 인원 Ajax 업데이트 function updateLeaveCount() { showLoading(); - fetch('http://127.0.0.1:7979/DashBoard/TodayCountH') + fetch('/DashBoard/TodayCountH') .then(response => response.text()) .then(data => { const cleanData = data.replace(/"/g, ''); @@ -701,7 +701,7 @@ // 휴가자 목록 Ajax 업데이트 function updateHolidayList() { showLoading(); - fetch('http://127.0.0.1:7979/DashBoard/GetholyUser') + fetch('/DashBoard/GetholyUser') .then(response => response.json()) .then(data => { let tableRows = ''; @@ -780,7 +780,7 @@ // 구매요청 데이터 Ajax 업데이트 function updatePurchaseCount() { showLoading(); - fetch('http://127.0.0.1:7979/DashBoard/GetPurchaseWaitCount') + fetch('/DashBoard/GetPurchaseWaitCount') .then(response => response.json()) .then(data => { if (data) { @@ -805,7 +805,7 @@ // 휴가요청 데이터 Ajax 업데이트 function updateHolydayRequestCount() { showLoading(); - fetch('http://127.0.0.1:7979/DashBoard/GetHolydayRequestCount') + fetch('/DashBoard/GetHolydayRequestCount') .then(response => response.json()) .then(data => { if (data) { @@ -825,7 +825,7 @@ // 사용자카운트 데이터 Ajax 업데이트 function updateCurrentUserCount() { showLoading(); - fetch('http://127.0.0.1:7979/DashBoard/GetCurrentUserCount') + fetch('/DashBoard/GetCurrentUserCount') .then(response => response.json()) .then(data => { if (data) { @@ -872,7 +872,7 @@ // Todo 목록 Ajax 업데이트 function updateTodoList() { showLoading(); - fetch('http://127.0.0.1:7979/Todo/GetUrgentTodos') + fetch('/Todo/GetUrgentTodos') .then(response => response.json()) .then(data => { if (data.Success && data.Data) { @@ -1288,7 +1288,7 @@ // 출근 대상자 목록 로드 function loadPresentUserList() { showLoading(); - fetch('http://127.0.0.1:7979/DashBoard/GetPresentUserList') + fetch('/DashBoard/GetPresentUserList') .then(response => response.json()) .then(data => { let tableRows = ''; @@ -1373,7 +1373,7 @@ // 휴가요청 목록 로드 function loadHolidayRequestList() { showLoading(); - fetch('http://127.0.0.1:7979/DashBoard/GetholyRequestUser') + fetch('/DashBoard/GetholyRequestUser') .then(response => response.json()) .then(data => { let tableRows = ''; @@ -1463,7 +1463,7 @@ // 구매NR 목록 로드 function loadPurchaseNRList() { showLoading(); - fetch('http://127.0.0.1:7979/DashBoard/GetPurchaseNRList') + fetch('/DashBoard/GetPurchaseNRList') .then(response => response.json()) .then(data => { let tableRows = ''; @@ -1538,7 +1538,7 @@ // 구매CR 목록 로드 function loadPurchaseCRList() { showLoading(); - fetch('http://127.0.0.1:7979/DashBoard/GetPurchaseCRList') + fetch('/DashBoard/GetPurchaseCRList') .then(response => response.json()) .then(data => { let tableRows = ''; diff --git a/Project/Web/wwwroot/login.html b/Project/Web/wwwroot/login.html index f61eb94..5ce98b8 100644 --- a/Project/Web/wwwroot/login.html +++ b/Project/Web/wwwroot/login.html @@ -280,7 +280,7 @@ showLoading(); // HomeController의 로그인 API 호출 - fetch('http://127.0.0.1:7979/Home/Login', { + fetch('/Home/Login', { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -373,7 +373,7 @@ // 그룹 목록 로드 function loadUserGroups() { - fetch('http://127.0.0.1:7979/DashBoard/GetUserGroups') + fetch('/DashBoard/GetUserGroups') .then(response => response.json()) .then(data => { const gcodeSelect = document.getElementById('gcode'); @@ -406,7 +406,7 @@ // 이전 로그인 정보 설정 function setPreviousLoginInfo() { // HomeController의 GetPreviousLoginInfo API 호출 - fetch('http://127.0.0.1:7979/Home/GetPreviousLoginInfo') + fetch('/Home/GetPreviousLoginInfo') .then(response => response.json()) .then(data => { if (data.Success && data.Data) { diff --git a/Project/fMain.cs b/Project/fMain.cs index 025fa19..8ae3d1a 100644 --- a/Project/fMain.cs +++ b/Project/fMain.cs @@ -121,21 +121,46 @@ namespace Project UpdateControls(); tmDisplay.Start(); //display timer - // Start OWIN host (실행환경 체크는 이미 완료됨) - try + // Start OWIN host with port fallback mechanism (포트 자동 탐색) + webok = false; + int startPort = 7979; + int maxPort = 8000; // 최대 8000 포트까지 시도 + + for (int port = startPort; port <= maxPort; port++) { - var options = new StartOptions(Pub.setting.WebServiceURL); - webApp = WebApp.Start(options); - Console.WriteLine("start webapp"); - FCOMMON.Pub.log.AddI("웹지원 서버 준비 완료"); - webok = true; - } - catch (Exception ex) - { - //Util.MsgE("Web Interface Error\r\n" + ex.Message)/; - Console.WriteLine(ex.Message); - FCOMMON.Pub.log.AddE("웹지원오류" + ex.Message); - webok = false; + try + { + var url = $"http://127.0.0.1:{port}"; + var options = new StartOptions(url); + webApp = WebApp.Start(options); + + // 성공 시 실제 사용된 포트 저장 + Pub.WebServiceURL = url; + + Console.WriteLine($"웹서버 시작 성공: {url}"); + FCOMMON.Pub.log.AddI($"웹지원 서버 준비 완료 (포트: {port})"); + + if (port != startPort) + { + FCOMMON.Pub.log.AddAT($"기본 포트({startPort})가 사용 중이어서 포트 {port}를 사용합니다."); + } + + webok = true; + break; // 성공하면 루프 종료 + } + catch (Exception ex) + { + Console.WriteLine($"포트 {port} 시작 실패: {ex.Message}"); + + // 마지막 포트까지 실패한 경우에만 에러 로그 + if (port == maxPort) + { + FCOMMON.Pub.log.AddE($"웹서버 시작 실패: 포트 {startPort}~{maxPort} 모두 사용 불가"); + FCOMMON.Pub.log.AddE("상세 오류: " + ex.Message); + webok = false; + } + // 다음 포트 시도 + } } // WebView2 초기화 재시도 (필요시)