Skip to content

Instantly share code, notes, and snippets.

@pacoyang
Created March 15, 2019 06:55
Show Gist options
  • Save pacoyang/9f3be265558cf7733adbfe909df0ebeb to your computer and use it in GitHub Desktop.
Save pacoyang/9f3be265558cf7733adbfe909df0ebeb to your computer and use it in GitHub Desktop.
from tornado.web import RequestHandler
class CorsHandler(RequestHandler):
def set_default_headers(self):
self.set_header(
'Access-Control-Allow-Origin',
self.request.headers.get('Origin', '*'))
self.set_header('Access-Control-Allow-Credentials', 'true')
self.set_header(
'Access-Control-Allow-Headers',
'X-Requested-With, Authorization')
self.set_header('Access-Control-Allow-Methods', 'POST, GET, OPTIONS')
def options(self):
self.set_status(204)
self.finish()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment