mirror of
https://github.com/luckfox-eng29/kvm.git
synced 2026-01-19 09:52:32 +01:00
feat: use the api url from device config (#161)
This commit is contained in:
23
ui/src/ui.config.ts
Normal file
23
ui/src/ui.config.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
interface JetKVMConfig {
|
||||
CLOUD_API?: string;
|
||||
CLOUD_APP?: string;
|
||||
DEVICE_VERSION?: string;
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface Window { JETKVM_CONFIG?: JetKVMConfig; }
|
||||
}
|
||||
|
||||
const getAppURL = (api_url?: string) => {
|
||||
if (!api_url) {
|
||||
return;
|
||||
}
|
||||
const url = new URL(api_url);
|
||||
url.host = url.host.replace(/api\./, "app.");
|
||||
// remove the ending slash
|
||||
return url.toString().replace(/\/$/, "");
|
||||
}
|
||||
|
||||
export const CLOUD_API = window.JETKVM_CONFIG?.CLOUD_API || import.meta.env.VITE_CLOUD_API;
|
||||
export const CLOUD_APP = window.JETKVM_CONFIG?.CLOUD_APP || getAppURL(CLOUD_API) || import.meta.env.VITE_CLOUD_APP;
|
||||
export const SIGNAL_API = import.meta.env.VITE_SIGNAL_API;
|
||||
Reference in New Issue
Block a user