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.

refactor(cloudcp): own commercial API config in Pulse Account

rcourtman5710168c3418
diff --git a/internal/cloudcp/portal/assets/portal.js b/internal/cloudcp/portal/assets/portal.js
index e332e66899..f06611e98b 100644
--- a/internal/cloudcp/portal/assets/portal.js
+++ b/internal/cloudcp/portal/assets/portal.js
@@ -1,4 +1,5 @@
-const LICENSE_API_BASE = 'https://license.pulserelay.pro';
+var portalRoot = document.querySelector('[data-commercial-api-base]');
+var LICENSE_API_BASE = portalRoot ? (portalRoot.getAttribute('data-commercial-api-base') || '') : '';
function showToast(msg, isError) {
var t = document.getElementById('toast');
diff --git a/internal/cloudcp/portal/handlers_test.go b/internal/cloudcp/portal/handlers_test.go
index 9658ca5c4d..4cfbdb9937 100644
--- a/internal/cloudcp/portal/handlers_test.go
+++ b/internal/cloudcp/portal/handlers_test.go
@@ -727,6 +727,7 @@ func TestPortalPageTemplate_AccountServicesRendered(t *testing.T) {
mustContain := []string{
"<title>Pulse Account</title>",
"Pulse Account",
+ `data-commercial-api-base="https://license.pulserelay.pro"`,
"Other account services",
`id="open-manage-service"`,
`id="open-retrieve-service"`,
@@ -751,6 +752,9 @@ func TestPortalPageTemplate_AccountServicesRendered(t *testing.T) {
t.Errorf("expected %q in rendered HTML", needle)
}
}
+ if strings.Contains(html, `const LICENSE_API_BASE = 'https://license.pulserelay.pro';`) {
+ t.Errorf("expected commercial API base URL to be renderer-owned, not hardcoded in the asset")
+ }
}
func TestPortalLoginTemplate_UsesPulseAccountBranding(t *testing.T) {
diff --git a/internal/cloudcp/portal/page.go b/internal/cloudcp/portal/page.go
index 1917028edc..61e02a44ae 100644
--- a/internal/cloudcp/portal/page.go
+++ b/internal/cloudcp/portal/page.go
@@ -34,13 +34,14 @@ type portalPageAccount struct {
// portalPageData is passed to the portal HTML template.
type portalPageData struct {
- Nonce string
- Email string
- PublicSiteURL string
- SupportEmail string
- Accounts []portalPageAccount
- Styles template.CSS
- Script template.JS
+ Nonce string
+ Email string
+ PublicSiteURL string
+ SupportEmail string
+ CommercialAPIBaseURL string
+ Accounts []portalPageAccount
+ Styles template.CSS
+ Script template.JS
}
type loginPageData struct {
@@ -50,8 +51,9 @@ type loginPageData struct {
}
const (
- defaultPublicSiteURL = "https://pulserelay.pro"
- defaultSupportEmail = "[email protected]"
+ defaultPublicSiteURL = "https://pulserelay.pro"
+ defaultSupportEmail = "[email protected]"
+ defaultCommercialAPIBaseURL = "https://license.pulserelay.pro"
)
// HandlePortalPage serves the MSP/Cloud portal dashboard (browser-facing HTML).
@@ -172,13 +174,14 @@ func renderPortalPage(w http.ResponseWriter, nonce, email string, accounts []por
w.Header().Set("Content-Type", "text/html; charset=utf-8")
w.WriteHeader(http.StatusOK)
if err := portalPageTmpl.Execute(w, portalPageData{
- Nonce: nonce,
- Email: email,
- PublicSiteURL: defaultPublicSiteURL,
- SupportEmail: defaultSupportEmail,
- Accounts: accounts,
- Styles: portalStyles,
- Script: portalScript,
+ Nonce: nonce,
+ Email: email,
+ PublicSiteURL: defaultPublicSiteURL,
+ SupportEmail: defaultSupportEmail,
+ CommercialAPIBaseURL: defaultCommercialAPIBaseURL,
+ Accounts: accounts,
+ Styles: portalStyles,
+ Script: portalScript,
}); err != nil {
log.Error().Err(err).Msg("cloudcp.portal.page: render portal page")
}
diff --git a/internal/cloudcp/portal/templates/portal.html b/internal/cloudcp/portal/templates/portal.html
index dca573e980..654fd445a4 100644
--- a/internal/cloudcp/portal/templates/portal.html
+++ b/internal/cloudcp/portal/templates/portal.html
@@ -14,7 +14,7 @@
</div>
</header>
-<main class="main">
+<main class="main" data-commercial-api-base="{{.CommercialAPIBaseURL}}">
<section class="intro-card">
<h1>Pulse Account</h1>
<p>Manage hosted Cloud and MSP workspaces here today. Self-hosted license and recovery tools still live on the public commercial surface during the current rollout, and are linked below so the account experience does not stay fragmented forever.</p>