Enable configuration of the server bind address.

A serverconfig.env (or just environment variables) can be set to
override the default bind address/port for the backend. This is passed
to the front end as a query parameter.
This commit is contained in:
Dan Albert
2022-03-07 17:52:33 -08:00
parent a70ab8cc1d
commit baae65919f
4 changed files with 18 additions and 7 deletions

View File

@@ -1,11 +1,15 @@
import axios from "axios";
export const HTTP_URL = "http://[::1]:1688/";
const backendAddr =
new URL(window.location.toString()).searchParams.get("server") ??
"[::1]:1688";
export const HTTP_URL = `http://${backendAddr}/`;
export const backend = axios.create({
baseURL: HTTP_URL,
});
export const WEBSOCKET_URL = "ws://[::1]:1688/eventstream";
export const WEBSOCKET_URL = `ws://${backendAddr}/eventstream`;
export default backend;