Skip to content

Commit 551a395

Browse files
szedan-rhclaude
andcommitted
fix: improve Grafana login routing by checking Referer header
The /login handler now checks both the redirectTo query parameter and the Referer header to properly detect Grafana login requests. This fixes the 405 Method Not Allowed error when logging into Grafana through the dashboard at /monitoring. Previous behavior: - Only checked redirectTo query parameter with "goto" string - POST requests from Grafana login form don't include this parameter - Requests were incorrectly routed to ChatUI which returns 405 New behavior: - Checks redirectTo parameter (for GET requests) - Checks Referer header for "/embedded/grafana" or "/monitoring" - Properly routes both GET and POST Grafana login requests Tested with: - Direct Grafana access: https://grafana-vllm-semantic-router-system.apps.cluster-hw4mm.hw4mm.sandbox590.opentlc.com (working) - Dashboard Grafana access: https://dashboard-vllm-semantic-router-system.apps.cluster-hw4mm.hw4mm.sandbox590.opentlc.com/monitoring (now working) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 725d7fa commit 551a395

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

dashboard/backend/router/router.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,18 @@ func Setup(cfg *config.Config) *http.ServeMux {
201201
if middleware.HandleCORSPreflight(w, r) {
202202
return
203203
}
204-
// Check if this is a Grafana login redirect by looking at the redirectTo parameter
204+
// Check if this is a Grafana login request by:
205+
// 1. Query parameter redirectTo with "goto" (GET requests)
206+
// 2. Referer header containing "/embedded/grafana" or "/monitoring" (POST requests)
205207
redirectTo := r.URL.Query().Get("redirectTo")
206-
if redirectTo != "" && strings.Contains(redirectTo, "goto") && grafanaStaticProxy != nil {
207-
log.Printf("Proxying Grafana login redirect: %s %s (redirectTo=%s)", r.Method, r.URL.Path, redirectTo)
208+
referer := r.Header.Get("Referer")
209+
210+
isGrafanaRequest := (redirectTo != "" && strings.Contains(redirectTo, "goto")) ||
211+
strings.Contains(referer, "/embedded/grafana") ||
212+
strings.Contains(referer, "/monitoring")
213+
214+
if isGrafanaRequest && grafanaStaticProxy != nil {
215+
log.Printf("Proxying Grafana login: %s %s (redirectTo=%s, referer=%s)", r.Method, r.URL.Path, redirectTo, referer)
208216
grafanaStaticProxy.ServeHTTP(w, r)
209217
return
210218
}

0 commit comments

Comments
 (0)