diff --git a/config/config.go b/config/config.go index 22aec59..f000f1e 100644 --- a/config/config.go +++ b/config/config.go @@ -10,7 +10,12 @@ import ( ) type HTTPServer struct { - Port int `koanf:"port"` + Port int `koanf:"port"` + Cors Cors `koanf:"cors"` +} + +type Cors struct { + AllowOrigins []string `koanf:"allow_origins"` } type Config struct { diff --git a/delivery/http_server/server.go b/delivery/http_server/server.go index 0d1ceca..780dca8 100644 --- a/delivery/http_server/server.go +++ b/delivery/http_server/server.go @@ -67,6 +67,9 @@ func (s Server) Serve() { func (s Server) RegisterRoutes() { s.Router.Use(middleware.RequestID()) s.Router.Use(middleware.Recover()) + s.Router.Use(middleware.CORSWithConfig(middleware.CORSConfig{ + AllowOrigins: s.config.HTTPServer.Cors.AllowOrigins, + })) registerSwagger(s.Router) // Routes diff --git a/deploy/stage/app/config.yml b/deploy/stage/app/config.yml index dd6c42a..dcd27e6 100644 --- a/deploy/stage/app/config.yml +++ b/deploy/stage/app/config.yml @@ -3,6 +3,9 @@ type: yml http_server: port: 1313 + cors: + allow_origins: + - "*" benefactor_service: length_of_otp_code: 5