Python - 记一次FastAPI跨域问题
使用FastAPI开发接口时,跨域调用报错如下:
1 | Access to XMLHttpRequest at 'http://xxxxxxxxxx' from origin 'null' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. |
解决方案:
1 | from fastapi import FastAPI |
FastAPI原文CORS(跨源资源共享)介绍:https://fastapi.tiangolo.com/tutorial/cors/
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Pandolar's Blog!
评论