diff --git a/frontend/src/js/main.js b/frontend/src/js/main.js index c760f3277500ff991c855cdbe370e5dd41bb2989..efc40a4bbc3dc11c16d392bd7c458615a735907d 100644 --- a/frontend/src/js/main.js +++ b/frontend/src/js/main.js @@ -5,6 +5,11 @@ import "popper.js"; import "bootstrap"; import * as bootbox from "bootbox"; import "../css/override.css"; +import path from "path"; + +const BACKEND_URL = new URL(process.env.BACKEND_URL); +const backendEndpointURL = (endpoint) => + new URL(path.join(BACKEND_URL.pathname, endpoint), BACKEND_URL); let config = { type: Phaser.AUTO, @@ -86,8 +91,6 @@ function preload() { }); } -window.OetziWordsSiteUrlPrefix = process.env.BACKEND_URL; - let gameRunning = false; let player; let scene; @@ -218,7 +221,7 @@ function dispatchEnemy() { let e = new enemy(); axios - .post(window.OetziWordsSiteUrlPrefix + "GetImage", { + .post(backendEndpointURL("GetImage"), { sessionImages: imageInUse, }) .then(function (response) { @@ -310,7 +313,7 @@ class enemy { } axios - .post(window.OetziWordsSiteUrlPrefix + "CheckTranscription", { + .post(backendEndpointURL("CheckTranscription"), { refData: me.refData, transcription: result, deltaTime: deltaTime,