Skip to content

Commit 851d49c

Browse files
committed
MINOR: add MaxAge and AllowCredentials to CORS
1 parent ca3b33d commit 851d49c

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

configure_data_plane.go

+14-1
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,20 @@ func setupMiddlewares(handler http.Handler) http.Handler {
367367
// The middleware configuration happens before anything, this middleware also applies to serving the swagger.json document.
368368
// So this is a good place to plug in a panic handling middleware, logging and metrics
369369
func setupGlobalMiddleware(handler http.Handler) http.Handler {
370-
handleCORS := cors.AllowAll().Handler
370+
handleCORS := cors.New(cors.Options{
371+
AllowedOrigins: []string{"*"},
372+
AllowedMethods: []string{
373+
http.MethodHead,
374+
http.MethodGet,
375+
http.MethodPost,
376+
http.MethodPut,
377+
http.MethodPatch,
378+
http.MethodDelete,
379+
},
380+
AllowedHeaders: []string{"*"},
381+
AllowCredentials: true,
382+
MaxAge: 86400,
383+
}).Handler
371384
recovery := adapters.RecoverMiddleware(log.StandardLogger())
372385
logViaLogrus := adapters.LoggingMiddleware(log.StandardLogger())
373386
return (logViaLogrus(handleCORS(recovery(handler))))

0 commit comments

Comments
 (0)