mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 21:07:18 +00:00
1de230110d
* add in cors for web ui in val client and gateway flag * Merge branch 'master' into add-default-beacon-gateway * gateway cors value * Merge branch 'add-default-beacon-gateway' of github.com:prysmaticlabs/prysm into add-default-beacon-gateway * fix tests * Merge refs/heads/master into add-default-beacon-gateway
21 lines
398 B
Go
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)
|
|
}
|