在对代码进行一些修改之后,它像冠军一样工作
# initializationapp = Flask(__name__)app.config['SECRET_KEY'] = 'the quick brown fox jumps over the lazy dog'app.config['CORS_HEADERS'] = 'Content-Type'cors = CORS(app, resources={r"/foo": {"origins": "http://localhost:port"}})@app.route('/foo', methods=['POST'])@cross_origin(origin='localhost',headers=['Content- Type','Authorization'])def foo(): return request.json['inputVar']if __name__ == '__main__': app.run()我将*替换为localhost。由于我在许多博客和帖子中都读过,因此您应该允许访问特定域



