Skip to content

Commit

Permalink
Merge pull request #699 from 0xPolygonID/fix/cors
Browse files Browse the repository at this point in the history
fix: add CORS settings with AllowCredentials
  • Loading branch information
volodymyr-basiuk authored Jul 29, 2024
2 parents 011d006 + b5f2a98 commit 781f9dc
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion cmd/platform/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,19 @@ func main() {
serverHealth.Run(ctx, health.DefaultPingPeriod)

mux := chi.NewRouter()

corsMiddleware := cors.New(cors.Options{
AllowedOrigins: []string{"localhost", "127.0.0.1", "*"},
AllowedMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
AllowedHeaders: []string{"Accept", "Authorization", "Content-Type"},
AllowCredentials: true,
})

mux.Use(
chiMiddleware.RequestID,
log.ChiMiddleware(ctx),
chiMiddleware.Recoverer,
cors.Handler(cors.Options{AllowedOrigins: []string{"*"}}),
corsMiddleware.Handler,
chiMiddleware.NoCache,
)
api.HandlerWithOptions(
Expand Down

0 comments on commit 781f9dc

Please sign in to comment.