From 710a2dc3bc56d959ceae2a6f8d0a75d4d7f3f7fc Mon Sep 17 00:00:00 2001 From: Finessse Date: Mon, 29 Dec 2025 21:21:42 +0700 Subject: [PATCH] chore(api): update dashboard route configuration --- internal/api/proxypilot_dashboard.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/internal/api/proxypilot_dashboard.go b/internal/api/proxypilot_dashboard.go index ca903d05..6fb75833 100644 --- a/internal/api/proxypilot_dashboard.go +++ b/internal/api/proxypilot_dashboard.go @@ -5,6 +5,7 @@ import ( "net/http" "os" "path" + "regexp" "strings" "github.com/gin-gonic/gin" @@ -12,6 +13,9 @@ import ( "github.com/router-for-me/CLIProxyAPI/v6/internal/misc" ) +// ppMgmtKeyRegex matches existing pp-mgmt-key meta tags to be replaced +var ppMgmtKeyRegex = regexp.MustCompile(``) + func (s *Server) registerProxyPilotDashboardRoutes() { if s == nil || s.engine == nil { return @@ -45,8 +49,14 @@ func (s *Server) serveProxyPilotDashboard(c *gin.Context) { key = strings.TrimSpace(os.Getenv("MANAGEMENT_PASSWORD")) } if key != "" && s.managementRoutesEnabled.Load() { - meta := `` - html = strings.Replace(html, "", meta+"", 1) + newMeta := `` + // Replace existing pp-mgmt-key meta tag (e.g., test placeholder) with actual key + if ppMgmtKeyRegex.MatchString(html) { + html = ppMgmtKeyRegex.ReplaceAllString(html, newMeta) + } else { + // No existing tag found, add before + html = strings.Replace(html, "", newMeta+"", 1) + } } c.Header("Content-Type", "text/html; charset=utf-8")