mirror of
https://gitee.com/shikong-sk/gofiber-study
synced 2025-02-23 23:32:15 +08:00
配置 cors
This commit is contained in:
parent
37d46eda0e
commit
eacb63befc
@ -3,6 +3,7 @@ package app
|
|||||||
import (
|
import (
|
||||||
"github.com/goccy/go-json"
|
"github.com/goccy/go-json"
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
|
"github.com/gofiber/fiber/v2/middleware/cors"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
"gofiber.study.skcks.cn/common/config"
|
"gofiber.study.skcks.cn/common/config"
|
||||||
"gofiber.study.skcks.cn/common/errorx"
|
"gofiber.study.skcks.cn/common/errorx"
|
||||||
@ -73,6 +74,9 @@ func reloadApp(c *config.BasicConfig) *fiber.App {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// 允许 cors
|
||||||
|
global.App.Use(cors.New())
|
||||||
|
|
||||||
if c.Server.EnableRoutesMsg {
|
if c.Server.EnableRoutesMsg {
|
||||||
routes(global.App)
|
routes(global.App)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user