Files
周小舟andClaude Opus 5.5 1267e2b1a9 fix(security): 其他网页不能再读取本地后端的 API Key 或发起写请求
CORS 由 * + credentials 收紧为 AutoClip 自家来源;带 Origin 的写请求必须同源或在白名单内,
表单/multipart 简单请求也会被拦;桌面模式只接受本机 Host,防 DNS 重绑定。
调试路由默认不挂载,web 入口默认只听 127.0.0.1。Docker 局域网访问用 AUTOCLIP_ALLOWED_ORIGINS。

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-29 15:50:40 +08:00

32 lines
955 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""FastAPI应用入口点 - Web模式"""
import logging
from backend.app_factory import create_app
# 创建应用实例
app = create_app(mode="web")
logger = logging.getLogger(__name__)
if __name__ == "__main__":
import uvicorn
import sys
# 默认端口
port = 8000
# 检查命令行参数
if len(sys.argv) > 1:
for i, arg in enumerate(sys.argv):
if arg == "--port" and i + 1 < len(sys.argv):
try:
port = int(sys.argv[i + 1])
except ValueError:
logger.error(f"无效的端口号: {sys.argv[i + 1]}")
port = 8000
# 默认只听本机;Docker / 局域网访问显式设 AUTOCLIP_HOST=0.0.0.0(Dockerfile 的 CMD 自带 --host)
import os
host = os.getenv("AUTOCLIP_HOST", "127.0.0.1")
logger.info(f"启动服务器,地址: {host}:{port}")
uvicorn.run(app, host=host, port=port)