From 42f964fd181dbb8b139808b9be623470d4f0e40f Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sun, 14 Jul 2019 21:29:50 +0800 Subject: [PATCH] add cors support for static resources --- routers/routes/routes.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/routers/routes/routes.go b/routers/routes/routes.go index c81d56064c..27260baf04 100644 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -38,6 +38,7 @@ import ( "github.com/go-macaron/binding" "github.com/go-macaron/cache" "github.com/go-macaron/captcha" + "github.com/go-macaron/cors" "github.com/go-macaron/csrf" "github.com/go-macaron/i18n" "github.com/go-macaron/session" @@ -131,6 +132,9 @@ func NewMacaron() *macaron.Macaron { if setting.Protocol == setting.FCGI { m.SetURLPrefix(setting.AppSubURL) } + if setting.EnableCORS { + m.Use(cors.CORS(setting.CORSConfig)) + } m.Use(public.Custom( &public.Options{ SkipLogging: setting.DisableRouterLog,