prysm-pulse/beacon-chain/gateway/cors.go
Preston Van Loon 5241582ece
Add CORS preflight support (#5177)
* Add CORS preflight support

* lint

* clarify description
2020-03-23 13:17:17 -05:00

21 lines
398 B
Go

package gateway
import (
"net/http"
"github.com/rs/cors"
)
func newCorsHandler(srv http.Handler, allowedOrigins []string) http.Handler {
if len(allowedOrigins) == 0 {
return srv
}
c := cors.New(cors.Options{
AllowedOrigins: allowedOrigins,
AllowedMethods: []string{http.MethodPost, http.MethodGet},
MaxAge: 600,
AllowedHeaders: []string{"*"},
})
return c.Handler(srv)
}