This commit is contained in:
eson
2023-08-30 14:21:09 +08:00
parent fe6baf6e41
commit 09fb6c3a36
3 changed files with 11 additions and 5 deletions

View File

@@ -85,12 +85,12 @@ func main() {
fs := http.FileServer(http.Dir(vueBuild))
indexHtmlPath := vueBuild + "/index.html"
mux.Handle("/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
err := r.ParseMultipartForm(100 << 20)
if err != nil {
logx.Error(err)
}
if strings.HasPrefix(r.URL.Path, "/api/") {
err := r.ParseMultipartForm(100 << 20)
if err != nil {
logx.Error(err)
}
// 对/api开头的请求进行反向代理
proxy := httputil.NewSingleHostReverseProxy(apiURL)
proxy.ServeHTTP(w, r)