添加原始请求的查询参数到目标URL,以确保代理请求能够正确传递查询信息。

This commit is contained in:
wood chen 2025-05-05 21:51:51 +08:00
parent 0335640df5
commit d1db2835b4

View File

@ -247,6 +247,11 @@ func (h *ProxyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
encodedPath := strings.Join(parts, "/")
targetURL := targetBase + encodedPath
// 添加原始请求的查询参数
if r.URL.RawQuery != "" {
targetURL = targetURL + "?" + r.URL.RawQuery
}
// 解析目标 URL 以获取 host
parsedURL, err := url.Parse(targetURL)
if err != nil {