From 3c0da3e81a9bb1ff128242f47f63b8ea1910fda5 Mon Sep 17 00:00:00 2001 From: Jason Cameron Date: Tue, 17 Sep 2024 18:52:38 -0400 Subject: [PATCH] Fix: Allow Authorization header on CO Requests. closes #2 --- main.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 8db227f..cbe6429 100644 --- a/main.go +++ b/main.go @@ -78,7 +78,15 @@ func main() { utils.InitializeStats(Client) // Initialize the Gin router r := gin.Default() - r.Use(cors.Default()) + // Cors + corsConfig := cors.Config{ + AllowMethods: []string{"GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"}, + AllowHeaders: []string{"Origin", "Content-Length", "Content-Type", "Authorization"}, + AllowCredentials: false, + AllowAllOrigins: true, + MaxAge: 12 * time.Hour, + } + r.Use(cors.New(corsConfig)) if os.Getenv("API_ANALYTICS_ENABLED") == "true" { r.Use(analytics.Analytics(os.Getenv("API_ANALYTICS_KEY"))) // Add middleware log.Println("Analytics enabled")