Expand env in clash external-ui

This commit is contained in:
世界 2022-07-22 09:49:35 +08:00
parent 3838d3070d
commit 139127f1e4
No known key found for this signature in database
GPG key ID: CD109927C34A63C4

View file

@ -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)