mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-13 19:46:39 +00:00
rpc: disable CORS if user has not specified custom config
This commit is contained in:
parent
5884606ec3
commit
a6af56fa4d
1 changed files with 5 additions and 0 deletions
|
|
@ -162,6 +162,11 @@ func (srv *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func newCorsHandler(srv *Server, allowedOrigins []string) http.Handler {
|
func newCorsHandler(srv *Server, allowedOrigins []string) http.Handler {
|
||||||
|
// disable CORS support if user has not specified a custom CORS configuration
|
||||||
|
if len(allowedOrigins) == 0 {
|
||||||
|
return srv
|
||||||
|
}
|
||||||
|
|
||||||
c := cors.New(cors.Options{
|
c := cors.New(cors.Options{
|
||||||
AllowedOrigins: allowedOrigins,
|
AllowedOrigins: allowedOrigins,
|
||||||
AllowedMethods: []string{"POST", "GET"},
|
AllowedMethods: []string{"POST", "GET"},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue