From 746a5f4913b6099e65df291391603fd107b96629 Mon Sep 17 00:00:00 2001 From: William Gardner Date: Fri, 5 Apr 2024 20:57:26 -0700 Subject: [PATCH 1/5] Webapp: improve URL parsing for SSL support --- web/app/src/urls.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/web/app/src/urls.js b/web/app/src/urls.js index 9f15d7e0..cdc54561 100644 --- a/web/app/src/urls.js +++ b/web/app/src/urls.js @@ -4,15 +4,10 @@ let url = new URL(window.location.href); if (url.port == '8081') { url.port = '8080'; } -url.pathname = '/'; -const flamencoAPIURL = url.href; - -url.protocol = 'ws:'; -const websocketURL = url.href; const URLs = { - api: flamencoAPIURL, - ws: websocketURL, + api: `${url.protocol}//${url.hostname}:${url.port}/`, + ws: `${url.protocol.replace('http', 'ws')}//${url.hostname}:${url.port}/`, }; // console.log("Flamenco API:", URLs.api); -- 2.30.2 From 3b5a1e933a2d115cf5e5da05bc9f8193cfb2fc55 Mon Sep 17 00:00:00 2001 From: William Gardner Date: Fri, 5 Apr 2024 20:57:50 -0700 Subject: [PATCH 2/5] Webapp: commented out debug code --- web/app/src/urls.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/web/app/src/urls.js b/web/app/src/urls.js index cdc54561..2081dc6d 100644 --- a/web/app/src/urls.js +++ b/web/app/src/urls.js @@ -1,9 +1,9 @@ let url = new URL(window.location.href); // Uncomment this when the web interface is running on a different port than the // API, for example when using the Vite devserver. Set the API port here. -if (url.port == '8081') { - url.port = '8080'; -} +// if (url.port == '8081') { +// url.port = '8080'; +// } const URLs = { api: `${url.protocol}//${url.hostname}:${url.port}/`, -- 2.30.2 From 042ab2be001a19ec4bd99c6a88f59d617392bd11 Mon Sep 17 00:00:00 2001 From: William Gardner Date: Fri, 5 Apr 2024 21:35:01 -0700 Subject: [PATCH 3/5] Webapp: use Vite modes to override API port --- web/app/package.json | 2 +- web/app/src/urls.js | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/web/app/package.json b/web/app/package.json index be3bcd85..0d1d6bab 100644 --- a/web/app/package.json +++ b/web/app/package.json @@ -12,7 +12,7 @@ } ], "scripts": { - "dev": "vite --port 8081 --base /app/", + "dev": "vite --port 8081 --base /app/ --mode development", "build": "vite build", "preview": "vite preview --port 5050", "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path .gitignore" diff --git a/web/app/src/urls.js b/web/app/src/urls.js index 2081dc6d..c36f0b99 100644 --- a/web/app/src/urls.js +++ b/web/app/src/urls.js @@ -1,9 +1,11 @@ let url = new URL(window.location.href); -// Uncomment this when the web interface is running on a different port than the -// API, for example when using the Vite devserver. Set the API port here. -// if (url.port == '8081') { -// url.port = '8080'; -// } + +// When using Vite development mode, access the API on port 8080. +if (import.meta.env.MODE == 'development') { + url.port = '8080'; +} + +console.log(import.meta.env.MODE); const URLs = { api: `${url.protocol}//${url.hostname}:${url.port}/`, -- 2.30.2 From 2e90ee2a45d033f250d552ead495b155f316afda Mon Sep 17 00:00:00 2001 From: William Gardner Date: Fri, 5 Apr 2024 21:40:19 -0700 Subject: [PATCH 4/5] Webapp: removed debug logging --- web/app/src/urls.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/web/app/src/urls.js b/web/app/src/urls.js index c36f0b99..44eb85b5 100644 --- a/web/app/src/urls.js +++ b/web/app/src/urls.js @@ -5,8 +5,6 @@ if (import.meta.env.MODE == 'development') { url.port = '8080'; } -console.log(import.meta.env.MODE); - const URLs = { api: `${url.protocol}//${url.hostname}:${url.port}/`, ws: `${url.protocol.replace('http', 'ws')}//${url.hostname}:${url.port}/`, -- 2.30.2 From 5755fab6b0a753c040697403be64b3e5deb7ffa1 Mon Sep 17 00:00:00 2001 From: William Gardner Date: Mon, 8 Apr 2024 12:35:02 -0700 Subject: [PATCH 5/5] Webapp: Comment improvements --- web/app/src/urls.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/web/app/src/urls.js b/web/app/src/urls.js index 44eb85b5..9ac3b689 100644 --- a/web/app/src/urls.js +++ b/web/app/src/urls.js @@ -1,6 +1,8 @@ let url = new URL(window.location.href); -// When using Vite development mode, access the API on port 8080. +// When the web interface is running on a different port than the API, for +// example when using the Vite devserver, setting the Vite --mode flag to +// "development" will force port 8080 for the API. if (import.meta.env.MODE == 'development') { url.port = '8080'; } -- 2.30.2