mirror of
https://github.com/v2rayA/v2rayA.git
synced 2026-11-20 23:02:25 +03:00
fix: prevent panic when _nuxt directory does not exist in embed FS
- Wrap /_nuxt/* route registration in fs.Sub() error check
- When _nuxt directory is absent (gui build without ngui),
skip route registration entirely instead of passing an invalid
FS to statigz.FileServer which caused panic on Open('.')
This commit is contained in:
1 parent
a0146071af
commit
72c73687f0
1 file changed
+8
-7
@@ -76,15 +76,16 @@ func ServeGUI(r *gin.Engine) {
|
||||
})
|
||||
|
||||
// --- /_nuxt/* route (used by ngui Nuxt 3 build) ---
|
||||
// When _nuxt/ directory does not exist (legacy gui), statigz safely returns 404
|
||||
nuxtFS := webFS.(fs.ReadDirFS)
|
||||
// Only register the route when _nuxt/ directory exists in the embedded filesystem.
|
||||
// When it does not exist (e.g. legacy gui build), silently skip to avoid panic
|
||||
// in statigz.FileServer when the underlying FS does not support Open(".").
|
||||
if sub, subErr := fs.Sub(webFS, "_nuxt"); subErr == nil {
|
||||
nuxtFS = sub.(fs.ReadDirFS)
|
||||
nuxtFS := sub.(fs.ReadDirFS)
|
||||
ns := http.StripPrefix("/_nuxt", statigz.FileServer(nuxtFS))
|
||||
r.GET("/_nuxt/*w", func(c *gin.Context) {
|
||||
ns.ServeHTTP(c.Writer, c.Request)
|
||||
})
|
||||
}
|
||||
ns := http.StripPrefix("/_nuxt", statigz.FileServer(nuxtFS))
|
||||
r.GET("/_nuxt/*w", func(c *gin.Context) {
|
||||
ns.ServeHTTP(c.Writer, c.Request)
|
||||
})
|
||||
|
||||
f, err := webFS.Open("index.html")
|
||||
if err != nil {
|
||||
|
||||
Reference in new issue
Block a user