From 2d000d395797dc4fa8d3ea209f4d1ac98eabcc3e Mon Sep 17 00:00:00 2001 From: "Alex Ellis (OpenFaaS Ltd)" Date: Thu, 11 Jan 2024 17:43:58 +0000 Subject: [PATCH] Fix forwarding of request body during text streaming Signed-off-by: Alex Ellis (OpenFaaS Ltd) --- proxy/proxy.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/proxy/proxy.go b/proxy/proxy.go index 3f918d0..d7efedc 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -72,6 +72,9 @@ func NewHandlerFunc(config types.FaaSConfig, resolver BaseURLResolver, verbose b reverseProxy := httputil.ReverseProxy{} reverseProxy.Director = func(req *http.Request) { // At least an empty director is required to prevent runtime errors. + req.URL.Scheme = "http" + } + reverseProxy.ErrorHandler = func(w http.ResponseWriter, r *http.Request, err error) { } // Errors are common during disconnect of client, no need to log them. @@ -187,7 +190,9 @@ func proxyRequest(w http.ResponseWriter, originalReq *http.Request, proxyClient } if v := originalReq.Header.Get("Accept"); v == "text/event-stream" { - reverseProxy.ServeHTTP(w, proxyReq) + originalReq.URL = proxyReq.URL + + reverseProxy.ServeHTTP(w, originalReq) return }