Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

feat: add API token to WebSocket URL for authentication

rcourtman0146495c0eaa
diff --git a/frontend-modern/src/utils/url.ts b/frontend-modern/src/utils/url.ts
index 3cd88bed5a..6178a7a534 100644
--- a/frontend-modern/src/utils/url.ts
+++ b/frontend-modern/src/utils/url.ts
@@ -57,5 +57,24 @@ export function getPulseWebSocketUrl(path = '/ws'): string {
}
const protocol = origin.protocol === 'https:' ? 'wss:' : 'ws:';
- return `${protocol}//${origin.host}${normalizedPath}`;
+ let url = `${protocol}//${origin.host}${normalizedPath}`;
+
+ // Add API token as query parameter if available (WebSocket doesn't support headers)
+ // Import dynamically to avoid circular dependencies
+ try {
+ const storage = typeof window !== 'undefined' ? window.sessionStorage : null;
+ if (storage) {
+ const stored = storage.getItem('pulse_auth');
+ if (stored) {
+ const parsed = JSON.parse(stored);
+ if (parsed?.type === 'token' && parsed.value) {
+ url += `?token=${encodeURIComponent(parsed.value)}`;
+ }
+ }
+ }
+ } catch {
+ // Ignore storage errors
+ }
+
+ return url;
}