From 58f93c959d9b8abdceb05cc4e5eea73869c93e3f Mon Sep 17 00:00:00 2001 From: SDI Date: Fri, 19 Jun 2026 17:20:06 +0900 Subject: [PATCH] fix: use proxied api routes in frontend --- index.html | 1 - src/components/Modal/HWModal.ts | 10 +++++----- src/views/List/ListFactory.ts | 4 ++-- src/views/MapEditor.ts | 5 +++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/index.html b/index.html index ec81e9a..2d5898c 100644 --- a/index.html +++ b/index.html @@ -3,7 +3,6 @@ - 한맥가족 자산관리시스템 { try { - const res = await fetch(`http://${location.hostname}:3000/api/upload`, { + const res = await fetch(`${API_BASE_URL}/api/upload`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ fileName: file.name, fileData: reader.result }) @@ -704,7 +704,7 @@ class HwAssetModal extends BaseModal { private async fetchMapConfig() { try { - const res = await fetch(`http://${location.hostname}:3000/api/maps`); + const res = await fetch(`${API_BASE_URL}/api/maps`); this.dynamicMapConfig = await res.json(); } catch (err) { console.error('Failed to fetch map config:', err); } } @@ -901,7 +901,7 @@ class HwAssetModal extends BaseModal { private async fetchMasterComponents(): Promise { try { - const res = await fetch(`http://${location.hostname}:3000/api/hardware-components`); + const res = await fetch(`${API_BASE_URL}/api/hardware-components`); this.masterComponents = await res.json(); } catch (err) { console.error('Failed to fetch master components:', err); } } diff --git a/src/views/List/ListFactory.ts b/src/views/List/ListFactory.ts index c711373..6c51b6e 100644 --- a/src/views/List/ListFactory.ts +++ b/src/views/List/ListFactory.ts @@ -1,5 +1,5 @@ import { ASSET_SCHEMA, UI_TEXT } from '../../core/schema'; -import { dynamicSort, renderPageHeader, calculateAssetAge, formatInline, isWindows11Incompatible } from '../../core/utils'; +import { API_BASE_URL, dynamicSort, renderPageHeader, calculateAssetAge, formatInline, isWindows11Incompatible } from '../../core/utils'; import { setupTableSorting, SortState } from '../../core/tableHandler'; import { renderFilterBar, applyCommonFilters } from '../../core/filterHandler'; import { state } from '../../core/state'; @@ -203,7 +203,7 @@ export function createListView(container: HTMLElement, config: ListViewConfig) { const fetchMapConfig = async () => { try { - const res = await fetch(`http://${location.hostname}:3000/api/maps`); + const res = await fetch(`${API_BASE_URL}/api/maps`); dynamicMapConfig = await res.json(); } catch (err) { console.error('Failed to fetch map config:', err); } }; diff --git a/src/views/MapEditor.ts b/src/views/MapEditor.ts index 7e815d1..fd1d529 100644 --- a/src/views/MapEditor.ts +++ b/src/views/MapEditor.ts @@ -1,4 +1,5 @@ import { IMAGE_LOCATIONS } from '../components/Modal/SharedData'; +import { API_BASE_URL } from '../core/utils'; import { createIcons, X, Save, Trash2, ChevronLeft, ChevronRight } from 'lucide'; export class MapEditor { @@ -70,7 +71,7 @@ export class MapEditor { private async loadConfig() { try { - const res = await fetch(`http://${location.hostname}:3000/api/maps`); + const res = await fetch(`${API_BASE_URL}/api/maps`); this.allMapConfig = await res.json(); } catch (err) { console.error('Failed to load config:', err); @@ -169,7 +170,7 @@ export class MapEditor { this.saveBtn.disabled = true; this.saveBtn.textContent = '저장 중...'; - const res = await fetch(`http://${location.hostname}:3000/api/maps/save`, { + const res = await fetch(`${API_BASE_URL}/api/maps/save`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ path: this.currentPath, boxes: this.boxes })