Using the following code I get a panic
func CORS() gin.HandlerFunc {
allowedOrigins := []string{"https://example.com", "https://www.example.com"}
if v, ok := os.LookupEnv("ALLOW_LOCAL_HOST"); ok {
allowedOrigins = append(allowedOrigins, v)
}
config := cors.Config{
AllowOrigins: allowedOrigins,
}
return cors.New(config)
}
I get this panic
ERROR 2025-03-24T02:41:34.271704Z panic: bad origin: origins must contain '*' or include http://,https://
but if I slightly change it to
config := cors.Config{
AllowOrigins: []string{"https://example.com", "https://www.example.com"},
}
it works as expected?
Is this a bug?
If not What am I missing here?