From 139127f1e4261090bb5dad18c53e387110624433 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Fri, 22 Jul 2022 09:49:35 +0800 Subject: [PATCH] Expand env in clash external-ui --- experimental/clashapi/server.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/experimental/clashapi/server.go b/experimental/clashapi/server.go index 280d0dfd..0a127aab 100644 --- a/experimental/clashapi/server.go +++ b/experimental/clashapi/server.go @@ -23,6 +23,7 @@ import ( "github.com/go-chi/render" "github.com/goccy/go-json" "github.com/gorilla/websocket" + "os" ) var _ adapter.ClashServer = (*Server)(nil) @@ -76,7 +77,7 @@ func NewServer(router adapter.Router, logFactory log.ObservableFactory, options }) if options.ExternalUI != "" { chiRouter.Group(func(r chi.Router) { - fs := http.StripPrefix("/ui", http.FileServer(http.Dir(options.ExternalUI))) + fs := http.StripPrefix("/ui", http.FileServer(http.Dir(os.ExpandEnv(options.ExternalUI)))) r.Get("/ui", http.RedirectHandler("/ui/", http.StatusTemporaryRedirect).ServeHTTP) r.Get("/ui/*", func(w http.ResponseWriter, r *http.Request) { fs.ServeHTTP(w, r)