Skip to content

Commit b03c3a6

Browse files
Added CORS section in server config
1 parent 78fb80c commit b03c3a6

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

config/server.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
package config
22

3+
type CORS struct {
4+
AllowedOrigins []string `yaml:"allowed_origins"`
5+
}
6+
37
/* server deployment parameters */
48
type Server struct {
59
Host string `yaml:"host,omitempty"`
610
Port int `yaml:"port,omitempty"`
11+
Cors CORS `yaml:"cors"`
712
}
813

914
/* normalization function */
@@ -19,5 +24,10 @@ func (s *Server) Normalize() error {
1924
s.Port = 8080
2025
}
2126

27+
/* set default cors policy to localhost */
28+
if len(s.Cors.AllowedOrigins) == 0 {
29+
s.Cors.AllowedOrigins = append(s.Cors.AllowedOrigins, "http://localhost:3000")
30+
}
31+
2232
return nil
2333
}

0 commit comments

Comments
 (0)