diff --git a/hive/gateway/gateway.go b/hive/gateway/gateway.go index 62dd9648a..1f458c271 100644 --- a/hive/gateway/gateway.go +++ b/hive/gateway/gateway.go @@ -8,6 +8,7 @@ import ( "strings" "github.com/gofiber/fiber/v2" + "github.com/gofiber/fiber/v2/middleware/cors" "github.com/gofiber/fiber/v2/middleware/logger" "github.com/google/uuid" "github.com/mulgadc/hive/hive/awsec2query" @@ -100,6 +101,14 @@ func (gw *GatewayConfig) SetupRoutes() *fiber.App { return nil } + // Add CORS middleware for browser requests + app.Use(cors.New(cors.Config{ + AllowOrigins: "http://localhost:3000", + AllowMethods: "GET,POST,PUT,DELETE,HEAD,OPTIONS", + AllowHeaders: "*", + AllowCredentials: true, + })) + // Add authentication middleware for all requests app.Use(s3.SigV4AuthMiddleware)