Skip to content
Snippets Groups Projects

feat(conf): do not insert CORS middleware if ALLOWED_URL is "unset"

1 file
+ 8
4
Compare changes
  • Side-by-side
  • Inline
+ 8
4
@@ -17,10 +17,14 @@ func serve(sig chan os.Signal, db *leveldb.DB) error {
app := fiber.New()
// cors
app.Use(cors.New(cors.Config{
AllowOrigins: []string{conf[allowedURL]},
AllowHeaders: []string{"Origin", "Content-Type", "Accept"},
}))
if conf[allowedURL] != "unset" {
app.Use(cors.New(cors.Config{
AllowOrigins: []string{conf[allowedURL]},
AllowHeaders: []string{"Origin", "Content-Type", "Accept"},
}))
} else {
log.Println("CORS disabled")
}
var captcha fiber.Handler
hCaptchaEnable := conf[hCaptchaSiteKey] != "unset" && conf[hCaptchaSecretKey] != "unset"
Loading