Repos / s4g / 2b4ca50abc
commit 2b4ca50abc8c1088a36327166c77bb550d253b86
Author: Nhân <hi@imnhan.com>
Date:   Wed Jul 12 17:22:54 2023 +0700

    local server: redirect to correct Root dir

diff --git a/main.go b/main.go
index 3e36f1e..d718617 100644
--- a/main.go
+++ b/main.go
@@ -107,6 +107,11 @@ func handleServeCmd(folder, port string) {
 			http.StripPrefix(site.Root, http.FileServer(http.FS(fsys))),
 		),
 	)
+
+	if site.Root != "/" {
+		http.Handle("/", http.RedirectHandler(site.Root, http.StatusTemporaryRedirect))
+	}
+
 	err = http.ListenAndServe("127.0.0.1:"+port, nil)
 	if err != nil {
 		panic(err)