diff --git a/build_system.d b/build_system.d
index e5df173..a64da60 100755
--- a/build_system.d
+++ b/build_system.d
@@ -21,24 +21,8 @@ const API_BUILD = "mvn clean package spring-boot:repackage -DskipTests=true";
void main(string[] args) {
print("Building RailSignalAPI");
- string baseDomain = "localhost:8080";
- bool useHttps = false;
- if (args.length >= 2) {
- baseDomain = args[1];
- if (args.length >= 3 && args[2] == "secure") {
- useHttps = true;
- print("Will configure web app to use secure connections.");
- }
- }
- string apiUrl = format!"%s://%s/api"(useHttps ? "https" : "http", baseDomain);
- string wsUrl = format!"%s://%s/api/ws/app"(useHttps ? "wss" : "ws", baseDomain);
- print("Building web app using API url %s and WS url %s", apiUrl, wsUrl);
- sleepSeconds(3);
-
chdir("quasar-app");
print("Building app...");
- setEnv("RAIL_SIGNAL_API_URL", apiUrl);
- setEnv("RAIL_SIGNAL_WS_URL", wsUrl);
runOrQuit(APP_BUILD);
print("Copying dist from %s to %s", DIST_ORIGIN, DIST);
chdir("..");
@@ -49,15 +33,5 @@ void main(string[] args) {
print("Building API...");
runOrQuit(API_BUILD);
print("Build complete!");
- string jarFile = findFile(".", "\\.jar", false);
-
- print("Generating run script...");
- auto scriptFile = File("target/run.sh", "w");
- scriptFile.write("#!/usr/bin/bash\n");
- scriptFile.write("RAIL_SIGNAL_API_URL=http://localhost:8080/api\n");
- scriptFile.write("RAIL_SIGNAL_WS_URL=ws://localhost:8080/api/ws/app\n");
- scriptFile.write("java -jar " ~ jarFile ~ "\n");
- scriptFile.close();
- print("Script file generated.");
}
diff --git a/pom.xml b/pom.xml
index 17f1984..f8b2d0b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
nl.andrewl
rail-signal-api
- 2.0.0
+ 2.0.1
rail-signal-api
A simple API for tracking rail traffic in signalled blocks.
diff --git a/quasar-app/quasar.config.js b/quasar-app/quasar.config.js
index 828acf8..7a455a5 100644
--- a/quasar-app/quasar.config.js
+++ b/quasar-app/quasar.config.js
@@ -70,10 +70,10 @@ module.exports = configure(function (ctx) {
publicPath: "/app/",
// analyze: true,
- env: {
- API_URL: ctx.dev ? "http://localhost:8080/api" : process.env.RAIL_SIGNAL_API_URL,
- WS_URL: ctx.dev ? "ws://localhost:8080/api/ws/app" : process.env.RAIL_SIGNAL_WS_URL
- },
+ // env: {
+ // API_URL: ctx.dev ? "http://localhost:8080/api" : process.env.RAIL_SIGNAL_API_URL,
+ // WS_URL: ctx.dev ? "ws://localhost:8080/api/ws/app" : process.env.RAIL_SIGNAL_WS_URL
+ // },
// rawDefine: {}
// ignorePublicFolder: true,
// minify: "hidden",
diff --git a/quasar-app/src/api/constants.js b/quasar-app/src/api/constants.js
index bec15ce..260854c 100644
--- a/quasar-app/src/api/constants.js
+++ b/quasar-app/src/api/constants.js
@@ -1,4 +1,12 @@
-export const API_URL = process.env.API_URL;
-export const WS_URL = process.env.WS_URL;
-console.log("Using API url: " + API_URL);
-console.log("Using WS url: " + WS_URL);
+/*
+In development mode, we should use localhost:8080 as that's where the API is set
+to run. In production mode, this app is deployed under the same host as the API,
+so we can simply use `location.origin` and `location.host` to define our API and
+WS urls.
+ */
+export const API_URL = process.env.DEV
+ ? "http://localhost:8080/api"
+ : location.origin + "/api";
+export const WS_URL = process.env.DEV
+ ? "ws://localhost:8080/api/ws/app"
+ : (location.protocol === "https:" ? "wss://" : "ws://") + location.host + "/api/ws/app";
diff --git a/src/main/java/nl/andrewl/railsignalapi/live/websocket/WebsocketConfig.java b/src/main/java/nl/andrewl/railsignalapi/live/websocket/WebsocketConfig.java
index e6354dd..e20da92 100644
--- a/src/main/java/nl/andrewl/railsignalapi/live/websocket/WebsocketConfig.java
+++ b/src/main/java/nl/andrewl/railsignalapi/live/websocket/WebsocketConfig.java
@@ -33,6 +33,7 @@ public class WebsocketConfig implements WebSocketConfigurer {
.addInterceptors(componentInterceptor);
WebSocketHandlerRegistration appHandlerReg = registry.addHandler(appHandler, "/api/ws/app/*")
.addInterceptors(appInterceptor);
+// appHandlerReg.setAllowedOrigins("*");
// If we're in a development profile, allow any origin to access the app websocket.
// This is so that we can use a standalone JS dev server.
if (Set.of(env.getActiveProfiles()).contains("development")) {