Improvements to URL handling in the webapp allowing for SSL (when behind a proxy) #104296

Merged
Sybren A. Stüvel merged 5 commits from william-at-counter/flamenco:main into main 2024-04-11 15:00:55 +02:00
2 changed files with 8 additions and 11 deletions

View File

@ -12,7 +12,7 @@
} }
], ],
"scripts": { "scripts": {
"dev": "vite --port 8081 --base /app/", "dev": "vite --port 8081 --base /app/ --mode development",
"build": "vite build", "build": "vite build",
"preview": "vite preview --port 5050", "preview": "vite preview --port 5050",
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path .gitignore" "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path .gitignore"

View File

@ -1,18 +1,15 @@
let url = new URL(window.location.href); 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. // When the web interface is running on a different port than the API, for
william-at-counter marked this conversation as resolved Outdated

The new comment doesn't explain why this piece of code is there to begin with. Please do keep the explanation that when using Vite in dev mode, the web app runs on a different port than the API.

The new comment doesn't explain why this piece of code is there to begin with. Please do keep the explanation that when using Vite in dev mode, the web app runs on a different port than the API.
if (url.port == '8081') { // 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'; url.port = '8080';
} }
url.pathname = '/';
const flamencoAPIURL = url.href;
url.protocol = 'ws:';
const websocketURL = url.href;
const URLs = { const URLs = {
api: flamencoAPIURL, api: `${url.protocol}//${url.hostname}:${url.port}/`,
ws: websocketURL, ws: `${url.protocol.replace('http', 'ws')}//${url.hostname}:${url.port}/`,
}; };
// console.log("Flamenco API:", URLs.api); // console.log("Flamenco API:", URLs.api);