Added support for configuring CORS headers

This commit is contained in:
Anuruth Lertpiya
2025-10-04 08:43:45 +00:00
parent 1e5e86d2c3
commit 0e1bc8a352
4 changed files with 8 additions and 1 deletions

View File

@@ -57,6 +57,9 @@ type ServerConfig struct {
// Allowed origins for CORS (e.g., "http://localhost:3000")
AllowedOrigins []string `yaml:"allowed_origins"`
// Allowed headers for CORS (e.g., "Accept", "Authorization", "Content-Type", "X-CSRF-Token")
AllowedHeaders []string `yaml:"allowed_headers"`
// Enable Swagger UI for API documentation
EnableSwagger bool `yaml:"enable_swagger"`
@@ -136,6 +139,7 @@ func LoadConfig(configPath string) (AppConfig, error) {
Host: "0.0.0.0",
Port: 8080,
AllowedOrigins: []string{"*"}, // Default to allow all origins
AllowedHeaders: []string{"*"}, // Default to allow all headers
EnableSwagger: false,
},
Backends: BackendConfig{