diff --git a/API/Classes/Base/Config.py b/API/Classes/Base/Config.py
index 49a889043..c5d514feb 100644
--- a/API/Classes/Base/Config.py
+++ b/API/Classes/Base/Config.py
@@ -78,7 +78,8 @@ def validate_path(base_dir, user_input):
# EXTRACT_FOLDER = Path(OSEMOSYS_ROOT, "")
# SOLVERs_FOLDER = Path(OSEMOSYS_ROOT, 'WebAPP', 'SOLVERs')
-HEROKU_DEPLOY = 0
+HEROKU_DEPLOY = int(os.environ.get("HEROKU_DEPLOY", 0))
+API_BASE_URL = os.environ.get("API_BASE_URL", "")
AWS_SYNC = 0
PINNED_COLUMNS = ('Sc', 'Tech', 'Comm', 'Emis','Stg', 'Ts', 'MoO', 'UnitId', 'Se','Dt', 'Dtb', 'paramName','TechName', 'CommName', 'EmisName', 'ConName', 'MoId')
diff --git a/API/app.py b/API/app.py
index 458aad034..f59ff43ec 100644
--- a/API/app.py
+++ b/API/app.py
@@ -83,18 +83,12 @@
CORS(app)
-#potrebno kad je front end na drugom serveru 127.0.0.1
@app.after_request
def add_headers(response):
- if Config.HEROKU_DEPLOY == 0:
- #localhost
- response.headers.add('Access-Control-Allow-Origin', 'http://127.0.0.1')
- else:
- #HEROKU
- response.headers.add('Access-Control-Allow-Origin', 'https://osemosys.herokuapp.com/')
+ allowed_origin = Config.API_BASE_URL if Config.API_BASE_URL else 'http://127.0.0.1'
+ response.headers.add('Access-Control-Allow-Origin', allowed_origin)
response.headers.add('Access-Control-Allow-Credentials', 'true')
response.headers.add('Access-Control-Allow-Headers', 'Content-Type, Authorization')
- #response.headers['Content-Type'] = 'application/javascript'
return response
# @app.errorhandler(CustomException)
@@ -114,7 +108,7 @@ def home():
# syncS3.downloadSync(case, Config.DATA_STORAGE, Config.S3_BUCKET)
# #downoload param file from S3 bucket
# syncS3.downloadSync('Parameters.json', Config.DATA_STORAGE, Config.S3_BUCKET)
- return render_template('index.html')
+ return render_template('index.html', api_base_url=Config.API_BASE_URL)
@app.route("/getSession", methods=['GET'])
diff --git a/WebAPP/Classes/Base.Class.js b/WebAPP/Classes/Base.Class.js
index 40befa648..f074c1e3e 100644
--- a/WebAPP/Classes/Base.Class.js
+++ b/WebAPP/Classes/Base.Class.js
@@ -3,16 +3,13 @@ import { Html } from "./Html.Class.js";
import { SyncS3 } from "./SyncS3.Class.js";
export class Base {
- static HEROKU = 0;
static AWS_SYNC = 0;
//init sync flag to pull from S3 only one time when visit home page
static INIT_SYNC = 1;
static apiUrl() {
- if (this.HEROKU == 1) {
- return "https://osemosys.herokuapp.com/";
- }
- return `${window.location.origin}/`;
+ const base = window.API_BASE_URL || window.location.origin;
+ return `${base}/`;
}
static initSyncS3() {
diff --git a/WebAPP/index.html b/WebAPP/index.html
index c3d56fe99..996cdc907 100644
--- a/WebAPP/index.html
+++ b/WebAPP/index.html
@@ -83,6 +83,9 @@
+
+
+