Created
March 15, 2019 06:55
-
-
Save pacoyang/9f3be265558cf7733adbfe909df0ebeb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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