fix: use proxied api routes in frontend
This commit is contained in:
@@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>한맥가족 자산관리시스템</title>
|
<title>한맥가족 자산관리시스템</title>
|
||||||
<link rel="stylesheet"
|
<link rel="stylesheet"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { state, saveAsset, deleteAsset } from '../../core/state';
|
import { state, saveAsset, deleteAsset } from '../../core/state';
|
||||||
import { ASSET_SCHEMA, UI_TEXT } from '../../core/schema';
|
import { ASSET_SCHEMA, UI_TEXT } from '../../core/schema';
|
||||||
import { calculatePcScoreDeductive, getPcGrade } from '../../core/utils';
|
import { API_BASE_URL, calculatePcScoreDeductive, getPcGrade } from '../../core/utils';
|
||||||
import {
|
import {
|
||||||
generateOptionsHTML,
|
generateOptionsHTML,
|
||||||
setFieldValue,
|
setFieldValue,
|
||||||
@@ -299,7 +299,7 @@ class HwAssetModal extends BaseModal {
|
|||||||
const prefix = TYPE_PREFIX_MAP[cat] || 'ETC';
|
const prefix = TYPE_PREFIX_MAP[cat] || 'ETC';
|
||||||
const purchaseDate = (document.getElementById('hw-purchase_date') as HTMLInputElement)?.value || '';
|
const purchaseDate = (document.getElementById('hw-purchase_date') as HTMLInputElement)?.value || '';
|
||||||
try {
|
try {
|
||||||
const res = await fetch(`http://${location.hostname}:3000/api/generate-asset-code?prefix=${prefix}&purchaseDate=${purchaseDate}`);
|
const res = await fetch(`${API_BASE_URL}/api/generate-asset-code?prefix=${prefix}&purchaseDate=${purchaseDate}`);
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
if (data.nextCode) setFieldValue('hw-asset_code', data.nextCode);
|
if (data.nextCode) setFieldValue('hw-asset_code', data.nextCode);
|
||||||
} catch (err) { console.error('코드 생성 실패:', err); }
|
} catch (err) { console.error('코드 생성 실패:', err); }
|
||||||
@@ -317,7 +317,7 @@ class HwAssetModal extends BaseModal {
|
|||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
reader.onload = async () => {
|
reader.onload = async () => {
|
||||||
try {
|
try {
|
||||||
const res = await fetch(`http://${location.hostname}:3000/api/upload`, {
|
const res = await fetch(`${API_BASE_URL}/api/upload`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify({ fileName: file.name, fileData: reader.result })
|
body: JSON.stringify({ fileName: file.name, fileData: reader.result })
|
||||||
@@ -704,7 +704,7 @@ class HwAssetModal extends BaseModal {
|
|||||||
|
|
||||||
private async fetchMapConfig() {
|
private async fetchMapConfig() {
|
||||||
try {
|
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();
|
this.dynamicMapConfig = await res.json();
|
||||||
} catch (err) { console.error('Failed to fetch map config:', err); }
|
} catch (err) { console.error('Failed to fetch map config:', err); }
|
||||||
}
|
}
|
||||||
@@ -901,7 +901,7 @@ class HwAssetModal extends BaseModal {
|
|||||||
|
|
||||||
private async fetchMasterComponents(): Promise<void> {
|
private async fetchMasterComponents(): Promise<void> {
|
||||||
try {
|
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();
|
this.masterComponents = await res.json();
|
||||||
} catch (err) { console.error('Failed to fetch master components:', err); }
|
} catch (err) { console.error('Failed to fetch master components:', err); }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { ASSET_SCHEMA, UI_TEXT } from '../../core/schema';
|
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 { setupTableSorting, SortState } from '../../core/tableHandler';
|
||||||
import { renderFilterBar, applyCommonFilters } from '../../core/filterHandler';
|
import { renderFilterBar, applyCommonFilters } from '../../core/filterHandler';
|
||||||
import { state } from '../../core/state';
|
import { state } from '../../core/state';
|
||||||
@@ -203,7 +203,7 @@ export function createListView(container: HTMLElement, config: ListViewConfig) {
|
|||||||
|
|
||||||
const fetchMapConfig = async () => {
|
const fetchMapConfig = async () => {
|
||||||
try {
|
try {
|
||||||
const res = await fetch(`http://${location.hostname}:3000/api/maps`);
|
const res = await fetch(`${API_BASE_URL}/api/maps`);
|
||||||
dynamicMapConfig = await res.json();
|
dynamicMapConfig = await res.json();
|
||||||
} catch (err) { console.error('Failed to fetch map config:', err); }
|
} catch (err) { console.error('Failed to fetch map config:', err); }
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { IMAGE_LOCATIONS } from '../components/Modal/SharedData';
|
import { IMAGE_LOCATIONS } from '../components/Modal/SharedData';
|
||||||
|
import { API_BASE_URL } from '../core/utils';
|
||||||
import { createIcons, X, Save, Trash2, ChevronLeft, ChevronRight } from 'lucide';
|
import { createIcons, X, Save, Trash2, ChevronLeft, ChevronRight } from 'lucide';
|
||||||
|
|
||||||
export class MapEditor {
|
export class MapEditor {
|
||||||
@@ -70,7 +71,7 @@ export class MapEditor {
|
|||||||
|
|
||||||
private async loadConfig() {
|
private async loadConfig() {
|
||||||
try {
|
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();
|
this.allMapConfig = await res.json();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Failed to load config:', err);
|
console.error('Failed to load config:', err);
|
||||||
@@ -169,7 +170,7 @@ export class MapEditor {
|
|||||||
this.saveBtn.disabled = true;
|
this.saveBtn.disabled = true;
|
||||||
this.saveBtn.textContent = '저장 중...';
|
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',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify({ path: this.currentPath, boxes: this.boxes })
|
body: JSON.stringify({ path: this.currentPath, boxes: this.boxes })
|
||||||
|
|||||||
Reference in New Issue
Block a user