From eacb63befc478c843d65e129ff09ba2547bc61fc Mon Sep 17 00:00:00 2001 From: Shikong <919411476@qq.com> Date: Sat, 29 Oct 2022 22:50:51 +0800 Subject: [PATCH] =?UTF-8?q?=E9=85=8D=E7=BD=AE=20cors?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/app.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/app.go b/app/app.go index 6d12ed5..3094d64 100644 --- a/app/app.go +++ b/app/app.go @@ -3,6 +3,7 @@ package app import ( "github.com/goccy/go-json" "github.com/gofiber/fiber/v2" + "github.com/gofiber/fiber/v2/middleware/cors" "github.com/spf13/viper" "gofiber.study.skcks.cn/common/config" "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 { routes(global.App) }