Add support for portless deploys

This commit is contained in:
2024-05-07 12:32:15 +01:00
parent dc1bd6cdfa
commit e3a5b5eaa1
4 changed files with 13 additions and 3 deletions

1
.env
View File

@@ -2,5 +2,6 @@ CLIENT_GRAPH_STEPS=150
CLIENT_PORT=3000 CLIENT_PORT=3000
CLIENT_REFETCH_INTERVAL=500 CLIENT_REFETCH_INTERVAL=500
SERVER_ACTIVE_WINDOW=5000 SERVER_ACTIVE_WINDOW=5000
SERVER_DEPLOY_URL=
SERVER_PORT=3001 SERVER_PORT=3001
SERVER_REFRESH_INTERVAL=500 SERVER_REFRESH_INTERVAL=500

View File

@@ -1,6 +1,8 @@
# SysMon Web # SysMon Web
A system monitor for the web. Data is read with rust, and displayed on the browser via HTML canvas A system monitor for the web. Data is read with rust, and displayed on the browser via HTML canvas.
[Live demo](https://sysmon.bate-estacas.xyz/)
![Screenshot 2024-05-06 at 18-49-44 SysMon Web](https://github.com/luisdralves/sysmon-web/assets/22676183/af08467d-50ae-4bd1-84d8-751f03b5fe11) ![Screenshot 2024-05-06 at 18-49-44 SysMon Web](https://github.com/luisdralves/sysmon-web/assets/22676183/af08467d-50ae-4bd1-84d8-751f03b5fe11)

View File

@@ -1,6 +1,12 @@
const getApiUrl = (path: string) => { const getApiUrl = (path: string) => {
const url = new URL(window.location.href); let url: URL;
url.port = import.meta.env.SERVER_PORT; try {
url = new URL(import.meta.env.SERVER_DEPLOY_URL as string);
} catch {
url = new URL(window.location.href);
url.port = import.meta.env.SERVER_PORT;
}
url.pathname = path; url.pathname = path;
return url; return url;

View File

@@ -5,6 +5,7 @@ interface ImportMetaEnv {
readonly CLIENT_PORT: string; readonly CLIENT_PORT: string;
readonly CLIENT_REFETCH_INTERVAL: string; readonly CLIENT_REFETCH_INTERVAL: string;
readonly SERVER_ACTIVE_WINDOW: string; readonly SERVER_ACTIVE_WINDOW: string;
readonly SERVER_DEPLOY_URL?: string;
readonly SERVER_PORT: string; readonly SERVER_PORT: string;
readonly SERVER_REFRESH_INTERVAL: string; readonly SERVER_REFRESH_INTERVAL: string;
} }