Skip to content

Commit

Permalink
restore CORS support. (#943)
Browse files Browse the repository at this point in the history
  • Loading branch information
tsachiherman authored Sep 8, 2023
1 parent 91595de commit d25a2d0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion cmd/soroban-rpc/internal/jsonrpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/creachadair/jrpc2/jhttp"
"github.com/go-chi/chi/middleware"
"github.com/prometheus/client_golang/prometheus"
"github.com/rs/cors"
"github.com/stellar/go/support/log"

"github.com/stellar/soroban-tools/cmd/soroban-rpc/internal/config"
Expand Down Expand Up @@ -277,9 +278,15 @@ func NewJSONRPCHandler(cfg *config.Config, params HandlerParams) Handler {
// Limit request sizes to 10MB
handler = http.MaxBytesHandler(handler, 1024*1024*10)

corsMiddleware := cors.New(cors.Options{
AllowedOrigins: []string{"*"},
AllowedHeaders: []string{"*"},
AllowedMethods: []string{"GET", "PUT", "POST", "PATCH", "DELETE", "HEAD", "OPTIONS"},
})

return Handler{
bridge: bridge,
logger: params.Logger,
Handler: handler,
Handler: corsMiddleware.Handler(handler),
}
}

0 comments on commit d25a2d0

Please sign in to comment.