From f766f8dfa4448fab0a0f5c4befab43615fea5314 Mon Sep 17 00:00:00 2001 From: Eli Ribble Date: Tue, 17 May 2016 11:07:48 -0600 Subject: [PATCH] Add basic CORS support I don't really need it yet, but I had added it in as I was trying to sort out how to get the UI working with the API --- vanth/server.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/vanth/server.py b/vanth/server.py index d695785..422d842 100644 --- a/vanth/server.py +++ b/vanth/server.py @@ -3,12 +3,17 @@ import uuid import flask import flask_login import flask_uuid +import sepiida.cors import sepiida.endpoints import vanth.api.about +import vanth.api.session import vanth.api.user import vanth.user +EXPOSE_HEADERS = [ + 'Location', +] def index(): return flask.render_template('index.html') @@ -45,6 +50,12 @@ def create_app(config): SECRET_KEY = config.secret_key, SESSION_COOKIE_DOMAIN = config.session_cookie_domain, ) + sepiida.cors.register_cors_handlers( + app, + domains=['localhost:8080', 'www.vanth.com'], + supports_credentials=True, + expose_headers=EXPOSE_HEADERS, + ) app.route('/', methods=['GET'])(index) app.route('/login/', methods=['GET', 'POST', 'DELETE'])(login)