Flask RESTful cross-domain issue with Angular: PUT, OPTIONS methods

前端 未结 9 1139
臣服心动
臣服心动 2020-12-12 17:14

I\'ve developed a small write-only REST api with Flask Restful that accepts PUT request from a handful of clients that can potentially have changing IP addresses. My clients

9条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-12 17:49

    I was facing the multiple types of CORS issue while connecting to my flask rest api from angular and tried almost all the approaches.
    If you want to give access to all the websites without any restriction you can add below code in you app.py script :

    from flask_cors import CORS , cross_origin
    
    cors = CORS(app, resources={r"/*": {"origins": "*"}})
    

    this will work, but its recommended to have some security which you can always edit in origin

提交回复
热议问题