The swarm UI's user menu moves to @hive/shared and takes the whoami URL and authelia's URL as props; the swarm UI keeps a thin wrapper, and the hive dashboard and the per-agent page mount the same component. The dashboard's nginx vhost proxies /api/whoami to authelia (the agent page is served from the same vhost), and hive-c0re's state carries authelia_public_url, set from services.hyperhive.swarm.authelia.url. The agent page shows the menu only behind the gateway.
16 lines
784 B
TypeScript
16 lines
784 B
TypeScript
// Resolves the host dashboard's origin, ported unchanged from app.js's
|
|
// `setHeader` — pause/resume are host-side (hive-c0re) actions, not
|
|
// this agent's own `/api/*`, so they need the *dashboard's* origin, not
|
|
// a relative path. Behind the gateway this page lives at
|
|
// `/agent/<name>/` on the dashboard's own origin (`location.origin`);
|
|
// accessed directly, it's the same host on `dashboardPort`.
|
|
/** Whether this page is served through the gateway, on the dashboard's origin. */
|
|
export function isBehindGateway(): boolean {
|
|
return location.pathname.startsWith("/agent/");
|
|
}
|
|
|
|
export function resolveDashboardBase(dashboardPort: number): string {
|
|
return isBehindGateway()
|
|
? location.origin + "/"
|
|
: `${location.protocol}//${location.hostname}:${dashboardPort}/`;
|
|
}
|