Update: Cors Origin from Docker Environments

This commit is contained in:
Yûki VACHOT 2022-01-14 01:35:50 +01:00
parent a398b49a98
commit 3615ae8d3b
3 changed files with 9 additions and 4 deletions

View file

@ -1,3 +1,4 @@
from flask import current_app as app
from flask import request, Blueprint
from flask_cors import CORS
from werkzeug.exceptions import HTTPException
@ -7,7 +8,10 @@ from .api_functions import db_login, db_register, db_user_update, db_create_log,
from .sessionJWT import create_auth_token, check_auth_token
bp = Blueprint('myapp', __name__)
CORS(bp, supports_credentials=True, origins=['http://127.0.0.1:4200', 'http://localhost:4200'])
origin = app.config.get('ALLOW_ORIGIN')
if origin is None:
origin = ['http://127.0.0.1:4200', 'http://localhost:4200']
CORS(bp, supports_credentials=True, origins=origin)
@bp.app_errorhandler(HTTPException)

View file

@ -21,7 +21,7 @@ class Config(object):
}
SECRET_KEY = os.environ.get('SECRET_KEY', 'default_secret_key')
ALLOW_ORIGIN = os.environ.get('ALLOW_ORIGIN', '*')
ALLOW_ORIGIN = os.environ.get('ALLOW_ORIGIN', None)
class ProductionConfig(Config):