From 9392a52d7c25452c63b28ec79de2b784d31284fa Mon Sep 17 00:00:00 2001 From: Nico Date: Tue, 22 Oct 2024 15:00:02 +0200 Subject: [PATCH 1/3] Create dependabot.yml --- .github/dependabot.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..d1b5f9a --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,13 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file + +version: 2 +updates: + - package-ecosystem: "gomod" # See documentation for possible values + directory: "/" # Location of package manifests + schedule: + interval: "weekly" + reviewers: + - "OnlyNico43" From 6e539b448f24b4fe60cd7004b099048adfba2093 Mon Sep 17 00:00:00 2001 From: Nico Benninger Date: Thu, 31 Oct 2024 13:25:28 +0100 Subject: [PATCH 2/3] feat: origin update --- cors.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cors.go b/cors.go index fae7f24..fea11f3 100644 --- a/cors.go +++ b/cors.go @@ -137,7 +137,7 @@ func CorsMiddleware(config Config) gin.HandlerFunc { } // Headers for all requests - c.Writer.Header().Set("Access-Control-Allow-Origin", strings.Join(config.AllowedOrigins, ", ")) + c.Writer.Header().Set("Access-Control-Allow-Origin", currentOrigin) c.Writer.Header().Set("Access-Control-Allow-Credentials", strconv.FormatBool(config.AllowCredentials)) c.Writer.Header().Set("Access-Control-Expose-Headers", strings.Join(config.ExposeHeaders, ", ")) From 7679ce47eebaefea2602481b705ca204cdb5759b Mon Sep 17 00:00:00 2001 From: Nico Benninger Date: Thu, 31 Oct 2024 13:28:43 +0100 Subject: [PATCH 3/3] fix: astericks in origin when present --- cors.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cors.go b/cors.go index fea11f3..4616a55 100644 --- a/cors.go +++ b/cors.go @@ -128,6 +128,10 @@ func CorsMiddleware(config Config) gin.HandlerFunc { c.AbortWithStatus(http.StatusForbidden) } + if slices.Contains(config.AllowedOrigins, "*") { + currentOrigin = "*" + } + preflight := strings.ToUpper(c.Request.Method) == "OPTIONS" if preflight { // Headers for preflight requests