This commit is contained in:
Yvan
2026-08-17 15:23:57 +08:00
parent 05b49cd86a
commit 083cc3a9ea
24 changed files with 639 additions and 287 deletions
+8 -2
View File
@@ -198,7 +198,11 @@ func (r *initializationRepo) Initialize(ctx context.Context, input *biz.Database
return err
}
}
ignoredAPIs := defaultIgnoredAPIs()
staticPath := "uploads/file"
if admin := r.data.runtime.Admin(); admin != nil && admin.Local != nil && strings.Trim(admin.Local.PathPrefix, "/") != "" {
staticPath = strings.Trim(admin.Local.PathPrefix, "/")
}
ignoredAPIs := defaultIgnoredAPIs(staticPath)
for _, ignored := range ignoredAPIs {
if err := tx.FirstOrCreate(&ignored, ignored).Error; err != nil {
return err
@@ -250,10 +254,12 @@ func (r *initializationRepo) Initialize(ctx context.Context, input *biz.Database
return nil
}
func defaultIgnoredAPIs() []ignoredAPIPO {
func defaultIgnoredAPIs(staticPath string) []ignoredAPIPO {
staticRoute := "/" + strings.Trim(staticPath, "/") + "/*filepath"
return []ignoredAPIPO{
{Method: "GET", Path: "/api/freshCasbin"}, {Method: "GET", Path: "/health"},
{Method: "GET", Path: "/swagger/*any"},
{Method: "GET", Path: staticRoute}, {Method: "HEAD", Path: staticRoute},
{Method: "POST", Path: "/system/reloadSystem"}, {Method: "POST", Path: "/base/login"},
{Method: "POST", Path: "/base/captcha"}, {Method: "POST", Path: "/init/initdb"},
{Method: "POST", Path: "/init/checkdb"}, {Method: "GET", Path: "/info/getInfoDataSource"},