def reapply_cors(request, response):
 service = request.current_service
 if service:
  request.info['cors_checked'] = False
  cors.apply_cors_post_request(service, request, response)
  response = cors.ensure_origin(service, request, response)
 else:
  origin = request.headers.get('Origin')
  if origin:
   settings = request.registry.settings
   allowed_origins = set(aslist(settings['cors_origins']))
   required_origins = {'*', decode_header(origin)}
   if allowed_origins.intersection(required_origins):
    origin = encode_header(origin)
    response.headers['Access-Control-Allow-Origin'] = origin
  from kinto.core import Service
  if Service.default_cors_headers:
   headers = ','.join(Service.default_cors_headers)
   response.headers['Access-Control-Expose-Headers'] = headers
 return response

def reapply_cors ( request , response ) : service = request . current_service if service : request . info [ 'cors_checked' ] = False cors . apply_cors_post_request ( service , request , response ) response = cors . ensure_origin ( service , request , response ) else : origin = request . headers . get ( 'Origin' ) if origin : settings = request . registry . settings allowed_origins = set ( aslist ( settings [ 'cors_origins' ] ) ) required_origins = { '*' , decode_header ( origin ) } if allowed_origins . intersection ( required_origins ) : origin = encode_header ( origin ) response . headers [ 'Access-Control-Allow-Origin' ] = origin from kinto . core import Service if Service . default_cors_headers : headers = ',' . join ( Service . default_cors_headers ) response . headers [ 'Access-Control-Expose-Headers' ] = headers return response
reapply cors headers to the new response with regards to the request .