当前位置:   article > 正文

fastapi跨域_fastapi 跨域

fastapi 跨域

1.不要用*号代替origins
2.不要用本地html做跨域测试,要用web服务测。 

  1. app = FastAPI()
  2. origins = [
  3. "http://localhost",
  4. "http://localhost:7146",
  5. "http://localhost:1880",
  6. "http://localhost:80",
  7. ]
  8. app.add_middleware(
  9. CORSMiddleware,
  10. allow_origins=origins,
  11. allow_credentials=True,
  12. allow_methods=["*"],
  13. allow_headers=["*"],
  14. )

声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号