ts
This commit is contained in:
+1
-1
@@ -82,7 +82,7 @@ MAX_LOGS = 10000 # 最大日志条数
|
||||
|
||||
# ========== Web 配置 ==========
|
||||
WEB_HOST = os.getenv("HOST", "0.0.0.0")
|
||||
WEB_PORT = int(os.getenv("PORT", "18080")) # 默认端口 18080,范围 10000-50000
|
||||
WEB_PORT = int(os.getenv("PORT", "18085")) # 默认端口 18085,范围 10000-50000
|
||||
SCREENSHOT_ON_ERROR = os.getenv("SCREENSHOT_ON_ERROR", "true").lower() == "true"
|
||||
|
||||
# ========== Git 更新配置 ==========
|
||||
|
||||
+11
@@ -15,6 +15,7 @@ from fastapi.templating import Jinja2Templates
|
||||
from fastapi.requests import Request
|
||||
from pydantic import BaseModel
|
||||
from typing import List as ListType
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
|
||||
from app import config
|
||||
from app.log_manager import get_log_manager
|
||||
@@ -61,6 +62,16 @@ log_manager = get_log_manager()
|
||||
# ========== FastAPI 应用 ==========
|
||||
app = FastAPI(title="小红书数据采集器", version="1.0.0")
|
||||
|
||||
# 添加 CORS 中间件
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=["*"], # 生产环境应该指定具体域名
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
expose_headers=["*"]
|
||||
)
|
||||
|
||||
# 挂载静态文件和模板
|
||||
app.mount("/static", StaticFiles(directory="static"), name="static")
|
||||
templates = Jinja2Templates(directory="templates")
|
||||
|
||||
Reference in New Issue
Block a user