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

View File

@@ -1,6 +1,12 @@
const getApiUrl = (path: string) => {
const url = new URL(window.location.href);
url.port = import.meta.env.SERVER_PORT;
let url: URL;
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;
return url;

View File

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