mirror of
https://github.com/googleapis/genai-toolbox.git
synced 2026-01-09 15:38:08 -05:00
Fixes that in SSL deployments, e.g. on k8s or cloud run the SSE endpoint was statically returning `http:` not a scheme based on request TLS attribute. Fixes https://github.com/googleapis/genai-toolbox/issues/419 --------- Co-authored-by: Yuan <45984206+Yuan325@users.noreply.github.com>
This commit is contained in:
@@ -126,8 +126,17 @@ func sseHandler(s *Server, w http.ResponseWriter, r *http.Request) {
|
||||
s.sseManager.add(sessionId, session)
|
||||
defer s.sseManager.remove(sessionId)
|
||||
|
||||
// https scheme formatting if (forwarded) request is a TLS request
|
||||
proto := r.Header.Get("X-Forwarded-Proto")
|
||||
if (proto == "") {
|
||||
if r.TLS == nil {
|
||||
proto = "http"
|
||||
} else {
|
||||
proto = "https"
|
||||
}
|
||||
}
|
||||
// send initial endpoint event
|
||||
messageEndpoint := fmt.Sprintf("http://%s/mcp?sessionId=%s", r.Host, sessionId)
|
||||
messageEndpoint := fmt.Sprintf("%s://%s/mcp?sessionId=%s", proto, r.Host, sessionId)
|
||||
s.logger.DebugContext(ctx, fmt.Sprintf("sending endpoint event: %s", messageEndpoint))
|
||||
fmt.Fprintf(w, "event: endpoint\ndata: %s\n\n", messageEndpoint)
|
||||
flusher.Flush()
|
||||
|
||||
Reference in New Issue
Block a user