fix: API URL 하드코딩 문제 해결 및 API 통합 개선

- API URL 생성 로직에서 localhost 환경 감지 개선
- 모든 페이지에서 하드코딩된 API URL 제거
- ManagementAPI, InboxAPI 추가로 API 호출 통합
- ProjectsAPI 사용으로 프로젝트 로드 통일
- permissions.js에서 API URL 동적 생성 적용
This commit is contained in:
hyungi
2025-11-08 15:34:37 +09:00
parent 637b690eda
commit 1299ac261c
6 changed files with 111 additions and 118 deletions

View File

@@ -6,8 +6,8 @@ const API_BASE_URL = (() => {
console.log('🔧 API URL 생성 - hostname:', hostname, 'protocol:', protocol, 'port:', port);
// 로컬 환경 (포트 있음)
if (port === '16080') {
// 로컬 환경 (localhost 또는 127.0.0.1이고 포트 있음)
if ((hostname === 'localhost' || hostname === '127.0.0.1') && port) {
const url = `${protocol}//${hostname}:${port}/api`;
console.log('🏠 로컬 환경 URL:', url);
return url;
@@ -256,6 +256,41 @@ const DailyWorkAPI = {
}
};
// Management API
const ManagementAPI = {
getAll: () => apiRequest('/management/'),
update: (issueId, updateData) => apiRequest(`/management/${issueId}`, {
method: 'PUT',
body: JSON.stringify(updateData)
}),
updateAdditionalInfo: (issueId, additionalInfo) => apiRequest(`/management/${issueId}/additional-info`, {
method: 'PUT',
body: JSON.stringify(additionalInfo)
})
};
// Inbox API
const InboxAPI = {
getAll: () => apiRequest('/inbox/'),
review: (issueId, reviewData) => apiRequest(`/inbox/${issueId}/review`, {
method: 'PUT',
body: JSON.stringify(reviewData)
}),
dispose: (issueId, disposeData) => apiRequest(`/inbox/${issueId}/dispose`, {
method: 'PUT',
body: JSON.stringify(disposeData)
}),
updateAdditionalInfo: (issueId, additionalInfo) => apiRequest(`/inbox/${issueId}/additional-info`, {
method: 'PUT',
body: JSON.stringify(additionalInfo)
})
};
// Reports API
const ReportsAPI = {
getSummary: (startDate, endDate) => apiRequest('/reports/summary', {

View File

@@ -46,7 +46,13 @@ class PagePermissionManager {
try {
// API에서 사용자별 페이지 권한 가져오기
const apiUrl = window.API_BASE_URL || 'http://localhost:16080/api';
const apiUrl = window.API_BASE_URL || (() => {
const hostname = window.location.hostname;
if (hostname === 'm.hyungi.net') {
return 'https://m-api.hyungi.net/api';
}
return '/api';
})();
const response = await fetch(`${apiUrl}/users/${this.currentUser.id}/page-permissions`, {
headers: {
'Authorization': `Bearer ${localStorage.getItem('access_token')}`