feat: 다수 기능 개선 - 순찰, 출근, 작업분석, 모바일 UI 등
- 순찰/점검 기능 개선 (zone-detail 페이지 추가) - 출근/근태 시스템 개선 (연차 조회, 근무현황) - 작업분석 대분류 그룹화 및 마이그레이션 스크립트 - 모바일 네비게이션 UI 추가 - NAS 배포 도구 및 문서 추가 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
89
deploy/tkfb-package/api.hyungi.net/config/cors.js
Normal file
89
deploy/tkfb-package/api.hyungi.net/config/cors.js
Normal file
@@ -0,0 +1,89 @@
|
||||
/**
|
||||
* CORS 설정
|
||||
*
|
||||
* Cross-Origin Resource Sharing 설정
|
||||
*
|
||||
* @author TK-FB-Project
|
||||
* @since 2025-12-11
|
||||
*/
|
||||
|
||||
const logger = require('../utils/logger');
|
||||
|
||||
/**
|
||||
* 허용된 Origin 목록
|
||||
*/
|
||||
const allowedOrigins = [
|
||||
'http://localhost:20000', // 웹 UI
|
||||
'http://localhost:3005', // API 서버
|
||||
'http://localhost:3000', // 개발 포트
|
||||
'http://127.0.0.1:20000', // 로컬호스트 대체
|
||||
'http://127.0.0.1:3005',
|
||||
'http://127.0.0.1:3000'
|
||||
];
|
||||
|
||||
/**
|
||||
* CORS 설정 옵션
|
||||
*/
|
||||
const corsOptions = {
|
||||
/**
|
||||
* Origin 검증 함수
|
||||
*/
|
||||
origin: function (origin, callback) {
|
||||
// Origin이 없는 경우 (직접 접근, Postman 등)
|
||||
if (!origin) {
|
||||
logger.debug('CORS: Origin 없음 - 허용');
|
||||
return callback(null, true);
|
||||
}
|
||||
|
||||
// 허용된 Origin 확인
|
||||
if (allowedOrigins.includes(origin)) {
|
||||
logger.debug('CORS: 허용된 Origin', { origin });
|
||||
return callback(null, true);
|
||||
}
|
||||
|
||||
// 개발 환경에서는 모든 localhost 허용
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
if (origin.includes('localhost') || origin.includes('127.0.0.1')) {
|
||||
logger.debug('CORS: 로컬호스트 허용 (개발 모드)', { origin });
|
||||
return callback(null, true);
|
||||
}
|
||||
}
|
||||
|
||||
// 로컬 네트워크 IP 자동 허용 (192.168.x.x)
|
||||
if (origin.match(/^http:\/\/192\.168\.\d+\.\d+(:\d+)?$/)) {
|
||||
logger.debug('CORS: 로컬 네트워크 IP 허용', { origin });
|
||||
return callback(null, true);
|
||||
}
|
||||
|
||||
// 차단
|
||||
logger.warn('CORS: 차단된 Origin', { origin });
|
||||
callback(new Error(`CORS 정책에 의해 차단됨: ${origin}`));
|
||||
},
|
||||
|
||||
/**
|
||||
* 인증 정보 포함 허용
|
||||
*/
|
||||
credentials: true,
|
||||
|
||||
/**
|
||||
* 허용된 HTTP 메소드
|
||||
*/
|
||||
methods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS'],
|
||||
|
||||
/**
|
||||
* 허용된 헤더
|
||||
*/
|
||||
allowedHeaders: ['Content-Type', 'Authorization', 'X-Requested-With'],
|
||||
|
||||
/**
|
||||
* 노출할 헤더
|
||||
*/
|
||||
exposedHeaders: ['Content-Range', 'X-Content-Range'],
|
||||
|
||||
/**
|
||||
* Preflight 요청 캐시 시간 (초)
|
||||
*/
|
||||
maxAge: 86400 // 24시간
|
||||
};
|
||||
|
||||
module.exports = corsOptions;
|
||||
Reference in New Issue
Block a user