def allow_cookie_domain(func):
""" 允许写cookie """
@wraps(func)
def wrapper_fun(*args, **kwargs):
""" wrapper_fun"""
rst = make_response(func(*args, **kwargs))
http_origin = request.headers['Origin'] if 'Origin' in request.headers.keys() else '*'
rst.headers['Content-type'] = 'application/json; charset=UTF-8'
rst.headers['Access-Control-Allow-Origin'] = http_origin
rst.headers['Access-Control-Allow-Credentials'] = 'true'
rst.headers['Access-Control-Allow-Methods'] = '*'
rst.headers['Access-Control-Allow-Headers'] = 'Content-Type,Accept,Authorization'
rst.headers['Access-Control-Max-Age'] = '86400'
return rst
return wrapper_fun
flask解决访问跨域问题
最新推荐文章于 2023-12-11 21:52:03 发布
关键词由CSDN通过智能技术生成