diff --git a/config/server.py b/config/server.py index 3869aa3..cf89594 100644 --- a/config/server.py +++ b/config/server.py @@ -11,7 +11,10 @@ session_opts = { 'session.auto': True } -# cors +def enable_cors(): + response.headers['Access-Control-Allow-Origin' ] = '*' + response.headers['Access-Control-Allow-Methods'] = 'GET, POST, PUT, DELETE, OPTIONS' + response.headers['Access-Control-Allow-Headers'] = 'Origin, Accept, Content-Type, X-Requested-With, X-CSRF-Token, Authorization' # error page 403 # error page 404 diff --git a/costa.py b/costa.py index 8bc8677..48ebbf7 100644 --- a/costa.py +++ b/costa.py @@ -16,6 +16,10 @@ from config import server app = Bottle() +@app.hook('after_request') +def after_request(): + server.enable_cors() + app.merge(handler.app) app.merge(staticdir.app)