diff --git a/api.py b/api.py index d611b8d..b8ea91c 100644 --- a/api.py +++ b/api.py @@ -3,13 +3,21 @@ import os import requests import uvicorn -from fastapi.responses import FileResponse from fastapi import FastAPI -from fastapi import FastAPI, Form +from fastapi.middleware.cors import CORSMiddleware env = os.environ app = FastAPI() +# 配置 CORS 中间件 +app.add_middleware( + CORSMiddleware, + allow_origins=["*"], # 允许所有来源,可以根据需求进行配置 + allow_credentials=True, + allow_methods=["*"], # 允许所有请求方法 + allow_headers=["*"], # 允许所有请求头 +) + # 榜单获取 @app.get("/get_rank")