Skip to content

Commit 1bbe9bb

Browse files
Merge branch 'development' into FE/migrations_clickhouse
2 parents fcfbcc0 + e557016 commit 1bbe9bb

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

pkg/middleware/cors.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
)
1111

1212
const (
13-
allowedHeaders = "Authorization, Content-Type, x-requested-with, true-client-ip, X-Correlation-ID"
13+
allowedHeaders = "Authorization, Content-Type, x-requested-with, origin, true-client-ip, X-Correlation-ID"
1414
allowedMethods = "PUT, POST, GET, DELETE, OPTIONS, PATCH"
1515
)
1616

@@ -47,6 +47,8 @@ func getValidCORSHeaders(envHeaders map[string]string) map[string]string {
4747

4848
// If config is not set - for the three headers, set default value.
4949
switch header {
50+
case "Access-Control-Allow-Origin":
51+
validCORSHeadersAndValues[header] = "*"
5052
case "Access-Control-Allow-Headers":
5153
validCORSHeadersAndValues[header] = allowedHeaders
5254
case "Access-Control-Allow-Methods":
@@ -66,6 +68,7 @@ func getValidCORSHeaders(envHeaders map[string]string) map[string]string {
6668
// AllowedCORSHeader returns the HTTP headers used for CORS configuration in web applications.
6769
func AllowedCORSHeader() []string {
6870
return []string{
71+
"Access-Control-Allow-Origin",
6972
"Access-Control-Allow-Headers",
7073
"Access-Control-Allow-Methods",
7174
"Access-Control-Allow-Credentials",

pkg/middleware/cors_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,20 @@ func Test_getValidCORSHeaders(t *testing.T) {
5757
}{
5858
{map[string]string{},
5959
map[string]string{
60+
"Access-Control-Allow-Origin": "*",
6061
"Access-Control-Allow-Headers": allowedHeaders,
6162
"Access-Control-Allow-Methods": allowedMethods,
6263
},
6364
},
6465
{map[string]string{
6566
"Access-Control-Max-Age": strconv.Itoa(600),
6667
"Access-Control-Allow-Headers": "",
68+
"Access-Control-Allow-Origin": "same-origin",
6769
"Access-Control-Allow-Methods": http.MethodPost,
6870
},
6971
map[string]string{
7072
"Access-Control-Max-Age": strconv.Itoa(600),
73+
"Access-Control-Allow-Origin": "same-origin",
7174
"Access-Control-Allow-Headers": allowedHeaders,
7275
"Access-Control-Allow-Methods": http.MethodPost,
7376
},
@@ -76,6 +79,7 @@ func Test_getValidCORSHeaders(t *testing.T) {
7679
"Access-Control-Allow-Headers": "clientid",
7780
},
7881
map[string]string{
82+
"Access-Control-Allow-Origin": "*",
7983
"Access-Control-Allow-Headers": allowedHeaders + ", clientid",
8084
"Access-Control-Allow-Methods": allowedMethods,
8185
},
@@ -89,6 +93,7 @@ func Test_getValidCORSHeaders(t *testing.T) {
8993
map[string]string{
9094
"Access-Control-Allow-Credentials": "true",
9195
"Access-Control-Max-Age": strconv.Itoa(600),
96+
"Access-Control-Allow-Origin": "*",
9297
"Access-Control-Allow-Headers": allowedHeaders,
9398
"Access-Control-Allow-Methods": allowedMethods,
9499
},

0 commit comments

Comments
 (0)