From 7fb55a7be73466f2b827ca9205df80351c819b57 Mon Sep 17 00:00:00 2001 From: gahusb Date: Tue, 27 Jan 2026 02:53:44 +0900 Subject: [PATCH] =?UTF-8?q?api/trade=20=EB=AF=B8=EB=8F=99=EC=9E=91=20?= =?UTF-8?q?=EB=AC=B8=EC=A0=9C=20=ED=95=B4=EA=B2=B0:=20CORS=20=ED=97=88?= =?UTF-8?q?=EC=9A=A9=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- stock-lab/app/main.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/stock-lab/app/main.py b/stock-lab/app/main.py index 4f2e986..ad94f97 100644 --- a/stock-lab/app/main.py +++ b/stock-lab/app/main.py @@ -1,5 +1,6 @@ import os from fastapi import FastAPI +from fastapi.middleware.cors import CORSMiddleware import requests from apscheduler.schedulers.background import BackgroundScheduler from pydantic import BaseModel @@ -8,6 +9,16 @@ from .db import init_db, save_articles, get_latest_articles from .scraper import fetch_market_news, fetch_major_indices, fetch_overseas_news app = FastAPI() + +# CORS 설정 (프론트엔드 접근 허용) +app.add_middleware( + CORSMiddleware, + allow_origins=["*"], # 운영 시에는 구체적인 도메인으로 제한하는 것이 좋음 + allow_credentials=True, + allow_methods=["*"], + allow_headers=["*"], +) + scheduler = BackgroundScheduler(timezone=os.getenv("TZ", "Asia/Seoul")) # Windows AI Server URL (NAS .env에서 설정)