Skip to content

Commit

Permalink
AllowedOrigins * for services
Browse files Browse the repository at this point in the history
  • Loading branch information
mboben committed Nov 7, 2023
1 parent 462c183 commit e9395a2
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions services/main/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"syscall"

"github.com/gorilla/mux"
"github.com/rs/cors"
)

func main() {
Expand All @@ -25,18 +26,22 @@ func main() {
routes.AddTransferRoutes(router, ctx)
routes.AddStakerRoutes(router, ctx)
routes.AddTransactionRoutes(router, ctx)

// Disabled -- state connector routes are currently not used
// routes.AddQueryRoutes(router, ctx)

if err := routes.AddMirroringRoutes(router, ctx); err != nil {
logger.Fatal("Failed to add mirroring routes: %v", err)
}

router.Finalize()

cors := cors.New(cors.Options{
AllowedOrigins: []string{"*"},
})
corsMuxRouter := cors.Handler(muxRouter)
address := ctx.Config().Services.Address
srv := &http.Server{
Handler: muxRouter,
Handler: corsMuxRouter,
Addr: address,
// Good practice: enforce timeouts for servers you create -- config?
// WriteTimeout: 15 * time.Second,
Expand Down

0 comments on commit e9395a2

Please sign in to comment.