def wrapped_function(*args, **kwargs): if request.method == "OPTIONS": resp = app.make_default_options_response() else: resp = make_response(f(*args, **kwargs)) patron_web_domains = app.manager.patron_web_domains if patron_web_domains: options = get_cors_options( app, dict(origins=patron_web_domains, supports_credentials=True)) set_cors_headers(resp, options) return resp
def wrapped_function(*args, **kwargs): if request.method == "OPTIONS": resp = app.make_default_options_response() else: resp = make_response(f(*args, **kwargs)) patron_web_domains = app.manager.patron_web_domains if patron_web_domains: options = get_cors_options( app, dict(origins=patron_web_domains, supports_credentials=True) ) set_cors_headers(resp, options) return resp
def wrapped_function(*args, **kwargs): if automatic_options and request.method == 'OPTIONS': resp = app.make_default_options_response() else: resp = make_response(f(*args, **kwargs)) if not attach_to_all and request.method != 'OPTIONS': return resp h = resp.headers h['Access-Control-Allow-Origin'] = origin h['Access-Control-Allow-Methods'] = get_methods() h['Access-Control-Max-Age'] = str(max_age) if headers is not None: h['Access-Control-Allow-Headers'] = headers return resp
def option_autoreply(): """ Always reply 200 on OPTIONS request """ if request.method == 'OPTIONS': resp = app.make_default_options_response() headers = None if 'ACCESS_CONTROL_REQUEST_HEADERS' in request.headers: headers = request.headers['ACCESS_CONTROL_REQUEST_HEADERS'] h = resp.headers # Allow the origin which made the XHR h['Access-Control-Allow-Origin'] = '*' # Allow the actual method h['Access-Control-Allow-Methods'] = request.headers['Access-Control-Request-Method'] # Allow for 10 seconds h['Access-Control-Max-Age'] = "10" # We also keep current headers if headers is not None: h['Access-Control-Allow-Headers'] = headers return resp
def before_request(): g.user = current_user if request.method == 'OPTIONS' and True: resp = app.make_default_options_response() headers = None if 'ACCESS_CONTROL_REQUEST_HEADERS' in request.headers: headers = request.headers['ACCESS_CONTROL_REQUEST_HEADERS'] h = resp.headers if 'ACCESS_CONTROL_REQUEST_HEADERS' in request.headers: headers = request.headers['ACCESS_CONTROL_REQUEST_HEADERS'] h = resp.headers h['Access-Control-Allow-Origin'] = request.headers['Origin'] h['Access-Control-Allow-Methods'] = request.headers['Access-Control-Req'] # Allow for 10 seconds h['Access-Control-Max-Age'] = "10" if headers is not None: h['Access-Control-Allow-Headers'] = headers return resp
def get_methods(): if methods is not None: return methods options_resp = app.make_default_options_response() return options_resp.headers['allow']