Serve embedded admin assets from root
This commit is contained in:
@@ -31,6 +31,10 @@ func Register(r *gin.Engine) {
|
||||
fileServer.ServeHTTP(c.Writer, c.Request)
|
||||
return
|
||||
}
|
||||
if strings.HasPrefix(reqPath, "assets/") {
|
||||
c.Status(http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
}
|
||||
// SPA fallback
|
||||
data, err := fs.ReadFile(sub, "index.html")
|
||||
@@ -43,7 +47,7 @@ func Register(r *gin.Engine) {
|
||||
|
||||
r.GET("/", handler)
|
||||
r.NoRoute(func(c *gin.Context) {
|
||||
if c.Request.Method != http.MethodGet || strings.HasPrefix(c.Request.URL.Path, "/api/") || c.Request.URL.Path == "/api" || strings.HasPrefix(c.Request.URL.Path, "/assets/") {
|
||||
if (c.Request.Method != http.MethodGet && c.Request.Method != http.MethodHead) || strings.HasPrefix(c.Request.URL.Path, "/api/") || c.Request.URL.Path == "/api" {
|
||||
c.Status(http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user