diff --git a/notebook/base/handlers.py b/notebook/base/handlers.py index 8b2cbc99f..993dd0151 100644 --- a/notebook/base/handlers.py +++ b/notebook/base/handlers.py @@ -386,6 +386,13 @@ class APIHandler(IPythonHandler): self.set_header('Content-Type', 'application/json') return super(APIHandler, self).finish(*args, **kwargs) + @web.authenticated + def options(self, *args, **kwargs): + self.set_header('Access-Control-Allow-Headers', 'accept, content-type') + self.set_header('Access-Control-Allow-Methods', + 'GET, PUT, PATCH, DELETE, OPTIONS') + self.finish() + class Template404(IPythonHandler): """Render our 404 template""" diff --git a/notebook/services/api/handlers.py b/notebook/services/api/handlers.py index 4600d6d41..c13b4721b 100644 --- a/notebook/services/api/handlers.py +++ b/notebook/services/api/handlers.py @@ -18,13 +18,6 @@ class APIHandler(web.StaticFileHandler, IPythonHandler): self.set_header('Content-Type', 'text/x-yaml') return web.StaticFileHandler.get(self, 'api.yaml') - @web.authenticated - def options(self, *args, **kwargs): - self.set_header('Access-Control-Allow-Headers', 'accept, content-type') - self.set_header('Access-Control-Allow-Methods', - 'GET, PUT, POST, PATCH, DELETE, OPTIONS') - self.finish() - default_handlers = [ (r"/api/spec.yaml", APIHandler) ]