Commit 7d4bc719 authored by Krish Moodbidri's avatar Krish Moodbidri
Browse files

added flask-cors and used allow cross_allowed_origins to fix the issue seen on...

added flask-cors and used allow cross_allowed_origins to fix the issue seen on prod cluster (400 CORS error)
parent bb267e98
Pipeline #4979 failed with stage
...@@ -7,6 +7,7 @@ import messages ...@@ -7,6 +7,7 @@ import messages
# third-party imports # third-party imports
import uuid import uuid
from flask import Flask, redirect, url_for, request, render_template, flash, session, send_from_directory from flask import Flask, redirect, url_for, request, render_template, flash, session, send_from_directory
from flask_cors import CORS
from flask_bootstrap import Bootstrap from flask_bootstrap import Bootstrap
import random import random
import os import os
...@@ -14,6 +15,7 @@ import json ...@@ -14,6 +15,7 @@ import json
def create_app(config_name): def create_app(config_name):
app = Flask(__name__, static_folder='static') # initialization of the flask app app = Flask(__name__, static_folder='static') # initialization of the flask app
cors = CORS(app, resources={r"/*": {"origins": "https://testshib1.dev.rc.uab.edu/"}})
Bootstrap(app) # allowing app to use bootstrap Bootstrap(app) # allowing app to use bootstrap
def get_authorized_user(): def get_authorized_user():
......
...@@ -7,6 +7,7 @@ Flask==1.1.1 ...@@ -7,6 +7,7 @@ Flask==1.1.1
Flask-Bootstrap==3.3.7.1 Flask-Bootstrap==3.3.7.1
Flask-SocketIO==4.2.1 Flask-SocketIO==4.2.1
Flask-Testing==0.7.1 Flask-Testing==0.7.1
Flask-Cors==3.0.10
gevent==1.4.0 gevent==1.4.0
greenlet==0.4.15 greenlet==0.4.15
importlib-metadata==1.5.0 importlib-metadata==1.5.0
......
...@@ -14,7 +14,7 @@ monkey.patch_all(subprocess=True) ...@@ -14,7 +14,7 @@ monkey.patch_all(subprocess=True)
config_name = os.getenv('FLASK_CONFIG') config_name = os.getenv('FLASK_CONFIG')
app = create_app(config_name) app = create_app(config_name)
app.config['SECRET_KEY'] = vars.key app.config['SECRET_KEY'] = vars.key
socketio = SocketIO(app, message_queue= vars.message_queue) socketio = SocketIO(app, cors_allowed_origins="https://testshib1.dev.rc.uab.edu", message_queue=vars.message_queue)
@socketio.on('join_room') @socketio.on('join_room')
def on_room(json): def on_room(json):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment