允许uayu

This commit is contained in:
2024-04-09 10:43:17 +08:00
parent 57fe832e38
commit ce06c5a0d4
13 changed files with 180 additions and 213 deletions
+9 -1
View File
@@ -7,6 +7,7 @@ import (
"sun-panel/router/panel"
"sun-panel/router/system"
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
)
@@ -15,7 +16,14 @@ func InitRouters(addr string) error {
router := gin.Default()
rootRouter := router.Group("/")
routerGroup := rootRouter.Group("api")
router.Use(cors.New(cors.Config{
// 允许所有源
AllowOrigins: []string{"*"},
// 允许所有方法
AllowMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
// 允许所有标头
AllowHeaders: []string{"*"},
}))
// 接口
system.Init(routerGroup)
panel.Init(routerGroup)