当我在开发模式(app.run)下运行此flask应用程序时,路由(“/countries”)运行良好并返回一个JSON数组,但是当我使用生产服务器(waitress)时,内容安全策略(CSP)会阻止路由加载数据
我收到的消息:内容安全策略:页面设置阻止加载http://localhost:5000/ (“默认src”)
我需要在CSP头上设置什么策略来避免这种情况发生?或者有什么我需要做的吗?多谢各位
@app.route('/counties', methods=['GET'])
def get_counties():
global sql
try:
counties = sql.get_counties()
return make_response (jsonify({'data':counties}), 200)
except:
return make_response(jsonify({'request':{}}), 500, )
@app.after_request
def add_header(response):
response.headers['Access-Control-Allow-Headers'] = '*'
response.headers['Access-Control-Allow-Origin'] = '*'
response.headers['Content-Security-Policy'] = "default-src 'self';"
return response
目前没有回答
相关问题 更多 >
编程相关推荐