fastapi 关闭跨域限制

非常简单

from fastapi import FastAPI from fastapi.middleware.cors import CORSMiddlewareapp = FastAPI()origins = [ "*" ]app.add_middleware( CORSMiddleware, allow_origins=origins, allow_credentials=True, allow_methods=["*"], allow_headers=["*"], )

【fastapi 关闭跨域限制】参考文章:
使用 CORSMiddleware

    推荐阅读