mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-26 13:18:57 +00:00
5241582ece
* Add CORS preflight support * lint * clarify description
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)
|
|
}
|