Update: CORS in INIT

This commit is contained in:
Yûki VACHOT 2022-01-14 17:29:02 +01:00
parent bb141b4bfb
commit 91e4bba793
2 changed files with 5 additions and 6 deletions

View file

@ -1,5 +1,6 @@
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_cors import CORS
import sys
db = SQLAlchemy()
@ -7,6 +8,10 @@ db = SQLAlchemy()
def create_app(flask_env='development'):
app = Flask(__name__, instance_relative_config=False)
origin = app.config.get('ALLOW_ORIGIN')
if origin is None:
origin = ['http://127.0.0.1:4200', 'http://localhost:4200']
CORS(app, supports_credentials=True, origins=origin)
if flask_env == 'production':
app.config.from_object("config.ProductionConfig")
elif flask_env == 'testing':