rux icon indicating copy to clipboard operation
rux copied to clipboard

StaticFS embed的路径问题

Open ismlsmile opened this issue 2 years ago • 1 comments

之前提的一个无法embed的问题,测试了下确实可以。但现在遇到一个embed的路径问题。 假设html的目录是static,目录下有index.html和main.js文件

//go:embed static
var embAssets embed.FS

r.StaticFS("/", http.FS(embAssets))

浏览器访问时需要输入:http://127.0.0.1:8080/static/index.html 但index.html中一般引入js的路径是http://127.0.0.1:8080/main.js 导致无法访问。所以希望在StaticFS中,能够把"static"这一层目录处理掉

ismlsmile avatar Aug 19 '22 01:08 ismlsmile

这个路径是 FS 控制的,大概翻了下,没找到怎么去掉一部分前缀路径

inhere avatar Aug 21 '22 06:08 inhere