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")