levelup beego + cors integration

This commit is contained in:
plm
2025-01-15 16:32:57 +01:00
parent 90ac9b4d44
commit f56a5d0dd3
3 changed files with 11 additions and 1 deletions

View File

@@ -5,6 +5,7 @@ import (
oclib "cloud.o-forge.io/core/oc-lib"
beego "github.com/beego/beego/v2/server/web"
"github.com/beego/beego/v2/server/web/filter/cors"
)
const appname = "oc-shared"
@@ -12,5 +13,12 @@ const appname = "oc-shared"
func main() {
// Init the oc-lib
oclib.Init(appname)
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()
}