From 27e2df2310355b970b5e6ed94f23e7ff28f397f5 Mon Sep 17 00:00:00 2001 From: plm Date: Wed, 15 Jan 2025 11:38:12 +0100 Subject: [PATCH] Support CORS --- main.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/main.go b/main.go index cd860bf..8daae6e 100644 --- a/main.go +++ b/main.go @@ -14,6 +14,7 @@ import ( "cloud.o-forge.io/core/oc-lib/models/utils" "cloud.o-forge.io/core/oc-lib/tools" beego "github.com/beego/beego/v2/server/web" + "github.com/beego/beego/v2/server/web/filter/cors" ) const appname = "oc-auth" @@ -52,6 +53,13 @@ func main() { panic(err) } discovery() + beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{ + AllowAllOrigins: true, + AllowMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"}, + AllowHeaders: []string{"Origin", "Authorization", "Content-Type"}, + ExposeHeaders: []string{"Content-Length", "Content-Type"}, + AllowCredentials: true, + })) beego.Run() }