Skip to content

Commit

Permalink
Remove CORS handling
Browse files Browse the repository at this point in the history
  • Loading branch information
patrislav committed Feb 20, 2024
1 parent e667b55 commit 904ef95
Showing 1 changed file with 0 additions and 19 deletions.
19 changes: 0 additions & 19 deletions rpc/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"github.com/aws/aws-sdk-go-v2/service/kms"
"github.com/go-chi/chi/v5"
"github.com/go-chi/chi/v5/middleware"
"github.com/go-chi/cors"
"github.com/go-chi/httplog"
"github.com/rs/zerolog"
)
Expand Down Expand Up @@ -188,24 +187,6 @@ func (s *RPC) Handler() http.Handler {
// Timeout any request after 28 seconds as Cloudflare has a 30 second limit anyways.
r.Use(middleware.Timeout(28 * time.Second))

// CORS
corsOptions := cors.Options{
AllowedOrigins: []string{"https://*"},
AllowedMethods: []string{"POST", "OPTIONS"},
AllowedHeaders: []string{
// TODO: in future we can remove "X-Sequence-Tenant" as its replaced by "X-Access-Key"
"Accept", "Authorization", "Content-Type", "X-Attestation-Nonce", "X-Sequence-Tenant", "X-Access-Key",
},
AllowCredentials: true,
MaxAge: 600,
}
if s.Config.Mode != config.ProductionMode {
corsOptions.AllowedOrigins = append(corsOptions.AllowedOrigins, "http://*")
}

c := cors.New(corsOptions)
r.Use(c.Handler)

// Quick pages
r.Use(middleware.PageRoute("/", http.HandlerFunc(indexHandler)))
r.Use(middleware.PageRoute("/status", http.HandlerFunc(s.statusHandler)))
Expand Down

0 comments on commit 904ef95

Please sign in to comment.