allowed origins moved to env

This commit is contained in:
nquidox 2025-09-29 21:49:25 +03:00
parent e3f893ac2d
commit 05ed7dc868
4 changed files with 24 additions and 17 deletions

View file

@ -21,9 +21,10 @@ type router struct {
}
type Deps struct {
ApiPrefix string
GinMode string
TokenProv interfaces.JWTProvider
ApiPrefix string
GinMode string
TokenProv interfaces.JWTProvider
AllowedOrigins []string
}
func NewRouter(deps Deps) interfaces.Router {
@ -39,7 +40,7 @@ func NewRouter(deps Deps) interfaces.Router {
}
engine.Use(cors.New(cors.Config{
AllowOrigins: []string{"http://localhost:5173"},
AllowOrigins: deps.AllowedOrigins,
AllowMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
AllowHeaders: []string{"Origin", "Content-Type", "Authorization"},
ExposeHeaders: []string{"Content-Length"},