cmd: Use viper for cors detection
@@ -25,7 +25,6 @@ import (
"fmt"
"net/http"
"net/url"
- "os"
"strings"
"sync"
@@ -46,6 +45,7 @@ import (
"github.com/pkg/errors"
"github.com/rs/cors"
"github.com/spf13/cobra"
+ "github.com/spf13/viper"
"github.com/urfave/negroni"
)
@@ -58,7 +58,7 @@ func enhanceRouter(c *config.Config, cmd *cobra.Command, serverHandler *Handler,
}
n.UseFunc(serverHandler.rejectInsecureRequests)
n.UseHandler(router)
- if os.Getenv("CORS_ENABLED") == "true" {
+ if viper.GetString("CORS_ENABLED") == "true" {
c.GetLogger().Info("Enabled CORS")
return context.ClearHandler(cors.New(corsx.ParseOptions()).Handler(n))
} else {
