Flask-Restful解决跨域问题No 'Access-Control-Allow-Origin' header is present on the requested resou

Posted SmallSky1997

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Flask-Restful解决跨域问题No 'Access-Control-Allow-Origin' header is present on the requested resou相关的知识,希望对你有一定的参考价值。

先简单介绍下我的平台:
前端:vue
后端:flask-restful

在前端调用后端接口的时候,报错

No \'Access-Control-Allow-Origin\' header is present on the requested resource.

找到后端文件/app/init.py,利用flask_cors中的CORS即可解决。

from flask_cors import CORS
app = Flask(__name__)
CORS(app)

以上是关于Flask-Restful解决跨域问题No 'Access-Control-Allow-Origin' header is present on the requested resou的主要内容,如果未能解决你的问题,请参考以下文章

Python3 - 初探 Flask-Restful

Python3 - 初探 Flask-Restful

No 'Access-Control-Allow-Origin' header is present之跨域问题及解决方案

Cors跨域请求问题

No 'Access-Control-Allow-Origin' Ajax跨域访问解决方案

解决跨域问题:No ‘Access-Control-Allow-Origin‘ header is present on the requested resource.