Skip to content

Commit 566b248

Browse files
committed
fix(CORS): adding CorsHandler can not work now after merge main, so the workaround it is, do not merge
1 parent 1ed99e8 commit 566b248

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

routers/web/web.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,24 @@ func Routes() *web.Route {
147147
routes.Get("/metrics", append(common, Metrics)...)
148148
}
149149

150+
///*
151+
if setting.CORSConfig.Enabled {
152+
corsHandle := cors.Handler(cors.Options{
153+
//Scheme: setting.CORSConfig.Scheme, // FIXME: the cors middleware needs scheme option
154+
AllowedOrigins: setting.CORSConfig.AllowDomain,
155+
//setting.CORSConfig.AllowSubdomain // FIXME: the cors middleware needs allowSubdomain option
156+
AllowedMethods: setting.CORSConfig.Methods,
157+
AllowedHeaders: []string{"*"},
158+
// OptionsPassthrough: true,
159+
Debug: true,
160+
AllowCredentials: setting.CORSConfig.AllowCredentials,
161+
MaxAge: int(setting.CORSConfig.MaxAge.Seconds()),
162+
})
163+
common = append(common, corsHandle)
164+
}
165+
//*/
166+
167+
150168
// Removed: toolbox.Toolboxer middleware will provide debug information which seems unnecessary
151169
common = append(common, context.Contexter())
152170

0 commit comments

Comments
 (0)