From 5aa6d754222a42d58005f62837790421b594f104 Mon Sep 17 00:00:00 2001 From: jones-187 Date: Sat, 4 Apr 2026 00:47:27 +0800 Subject: [PATCH] =?UTF-8?q?fix(proxy):=20=E4=BF=AE=E5=A4=8D=E5=8E=82?= =?UTF-8?q?=E5=95=86Base=20URL=E4=B8=ADpath=E9=83=A8=E5=88=86=E4=B8=8D?= =?UTF-8?q?=E7=94=9F=E6=95=88=EF=BC=8C=E4=BB=85host=E7=94=9F=E6=95=88?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/proxy/proxy.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/internal/proxy/proxy.go b/internal/proxy/proxy.go index dc42f74..3d2229b 100644 --- a/internal/proxy/proxy.go +++ b/internal/proxy/proxy.go @@ -10,6 +10,7 @@ import ( "net/http" "net/http/httputil" "net/url" + "strings" "sync" "time" @@ -112,6 +113,16 @@ func (p *ProxyServer) Start(ctx context.Context) error { req.URL.Scheme = "https" req.URL.Host = targetURL.Host req.Host = targetURL.Host + + if targetURL.Path != "" && targetURL.Path != "/" { + targetPath := strings.TrimSuffix(targetURL.Path, "/") + reqPath := req.URL.Path + if !strings.HasPrefix(reqPath, "/") { + reqPath = "/" + reqPath + } + req.URL.Path = targetPath + reqPath + } + log.Printf("[Proxy] %s %s -> https://%s%s", req.Method, req.URL.Path, targetURL.Host, req.URL.Path) }