@slicer.after_request
def add_cors_headers(response):
 origin = current_app.slicer.allow_cors_origin
 if (origin and len(origin)):
  if (request.method == 'OPTIONS'):
   response.headers['Access-Control-Allow-Headers'] = 'X-Requested-With'
  if (origin == '*'):
   response.headers['Access-Control-Allow-Origin'] = request.headers.get('Origin', origin)
  else:
   response.headers['Access-Control-Allow-Origin'] = origin
  response.headers['Access-Control-Allow-Credentials'] = 'true'
  response.headers['Access-Control-Allow-Methods'] = 'GET, POST, OPTIONS'
  response.headers['Access-Control-Max-Age'] = CORS_MAX_AGE
 return response

@ slicer . after_request def add_cors_headers ( response ) : origin = current_app . slicer . allow_cors_origin if ( origin and len ( origin ) ) : if ( request . method == 'OPTIONS' ) : response . headers [ 'Access-Control-Allow-Headers' ] = 'X-Requested-With' if ( origin == '*' ) : response . headers [ 'Access-Control-Allow-Origin' ] = request . headers . get ( 'Origin' , origin ) else : response . headers [ 'Access-Control-Allow-Origin' ] = origin response . headers [ 'Access-Control-Allow-Credentials' ] = 'true' response . headers [ 'Access-Control-Allow-Methods' ] = 'GET, POST, OPTIONS' response . headers [ 'Access-Control-Max-Age' ] = CORS_MAX_AGE return response
add cross-origin resource sharing headers .