chore: switched all urls to relative paths

This commit is contained in:
Davide Passoni
2024-12-09 10:18:58 +01:00
parent a4452aee94
commit 96899121f7
15 changed files with 43 additions and 52 deletions

View File

@@ -44,7 +44,6 @@ export class AudioManager {
/* The audio backend must be manually started so that the browser can detect the user is enabling audio.
Otherwise, no playback will be performed. */
#running: boolean = false;
#address: string = "localhost";
#port: number;
#endpoint: string;
#socket: WebSocket | null = null;
@@ -90,10 +89,10 @@ export class AudioManager {
this.#playbackPipeline = new PlaybackPipeline();
/* Connect the audio websocket */
let res = this.#address.match(/(?:http|https):\/\/(.+):/);
if (res === null) res = this.#address.match(/(?:http|https):\/\/(.+)/);
let res = location.toString().match(/(?:http|https):\/\/(.+):/);
if (res === null) res = location.toString().match(/(?:http|https):\/\/(.+)/);
let wsAddress = res ? res[1] : this.#address;
let wsAddress = res ? res[1] : location.toString();
if (this.#endpoint) this.#socket = new WebSocket(`wss://${wsAddress}/${this.#endpoint}`);
else if (this.#port) this.#socket = new WebSocket(`ws://${wsAddress}:${this.#port}`);
else console.error("The audio backend was enabled but no port/endpoint was provided in the configuration");
@@ -229,10 +228,6 @@ export class AudioManager {
AudioManagerStateChangedEvent.dispatch(this.#running);
}
setAddress(address) {
this.#address = address;
}
setPort(port) {
this.#port = port;
}

View File

@@ -15,7 +15,7 @@ export class SpeechController {
body: JSON.stringify({ data: base64 }), // Send the data in blob format
};
fetch(getApp().getExpressAddress() + `/api/speech/recognize`, requestOptions)
fetch(`./api/speech/recognize`, requestOptions)
.then((response) => {
if (response.status === 200) {
console.log(`Speech recognized correctly`);

View File

@@ -30,7 +30,7 @@ export class TextToSpeechSource extends AudioSource {
this.#loading = true;
fetch(getApp().getExpressAddress() + `/api/speech/generate`, requestOptions)
fetch(`./api/speech/generate`, requestOptions)
.then((response) => {
if (response.status === 200) {
console.log(`Text to speech generate correctly`);