我有以下代码:
r := mux.NewRouter()
r.Handle("/", http.FileServer(http.Dir("./frontend/build/")))
r.Handle("/static", http.FileServer(http.Dir("./frontend/build/static/")))
r.PathPrefix("/api").Handler(auth)
/api应该是安全的。如果用户点击/,我希望他们查看目录index.html中的。PROJECTDIR/frontend
前端目录看起来像
frontend
/build
index.html
/static
/js
/css
/media
index.html 从 加载所有内容/static。无论我如何配置它,当我访问时localhost:3000,我都可以得到index.html但下面的所有内容/static都是 404 的。
我如何错误地配置它?