用python的Flask写的服务器,web用ajax请求时候报这个错。
解决办法:
from flask import Flask, request
def after_request(response):
response.headers['Access-Control-Allow-Origin'] = '*'
response.headers['Access-Control-Allow-Methods'] = 'PUT,GET,POST,DELETE'
response.headers['Access-Control-Allow-Headers'] = 'Content-Type,Authorization'
return response
def create_app():
app = Flask(__name__)
app.after_request(after_request)