generated from methanium/template
(feat): some connection improvements
This commit is contained in:
parent
2058847d25
commit
d55b1326f8
4 changed files with 27 additions and 1 deletions
|
|
@ -4,6 +4,7 @@
|
|||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="theme-color" content="#171e26" />
|
||||
<link rel="icon" href="/methanium.svg" type="image/svg+xml" />
|
||||
<title>Methanium Status</title>
|
||||
<style>
|
||||
html.dark,
|
||||
|
|
|
|||
|
|
@ -15,12 +15,22 @@ function logMTP(event: MTPLogEvent) {
|
|||
}
|
||||
}
|
||||
|
||||
async function getMTPUrl() {
|
||||
const response = await fetch("/api/config");
|
||||
if (!response.ok) throw new Error("Failed to load MTP configuration");
|
||||
|
||||
const config = (await response.json()) as { public_port: number };
|
||||
const url = new URL(location.origin);
|
||||
url.port = String(config.public_port);
|
||||
return url.origin;
|
||||
}
|
||||
|
||||
export const mtpOptions: MTPClientOptions | null = location.pathname.startsWith(
|
||||
"/edit",
|
||||
)
|
||||
? null
|
||||
: {
|
||||
url: configuredUrl ?? `${location.origin}/mtp`,
|
||||
url: configuredUrl ?? (await getMTPUrl()),
|
||||
descriptor: "methanium-status-frontend",
|
||||
pings: false,
|
||||
logger: logMTP,
|
||||
|
|
|
|||
Loading…
Reference in a new issue