Add support for portless deploys
This commit is contained in:
@@ -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;
|
||||
|
||||
1
src/client/vite-env.d.ts
vendored
1
src/client/vite-env.d.ts
vendored
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user