Update CORS configuration in main.go

- Updated the handling of the ALLOWED_ORIGINS environment variable to ensure a default value of '*' is used when the variable is empty, improving the flexibility of CORS settings.
This commit is contained in:
2025-12-27 12:41:51 -06:00
parent 50521bf070
commit 52df2d76c1

View File

@@ -58,7 +58,11 @@ func main() {
r := chi.NewRouter()
allowedOrigins := strings.Split(getEnv("ALLOWED_ORIGINS", "*"), ",")
allowedOriginsStr := getEnv("ALLOWED_ORIGINS", "*")
if allowedOriginsStr == "" {
allowedOriginsStr = "*"
}
allowedOrigins := strings.Split(allowedOriginsStr, ",")
r.Use(cors.Handler(cors.Options{
AllowedOrigins: allowedOrigins,
AllowedMethods: []string{"GET", "POST", "OPTIONS"},