added allow origins func
This commit is contained in:
parent
91abc28f42
commit
70b8aa104e
6
main.go
6
main.go
@ -26,7 +26,6 @@ func main() {
|
|||||||
cors_config.AllowOrigins = []string{"https://games.acooldomain.co"}
|
cors_config.AllowOrigins = []string{"https://games.acooldomain.co"}
|
||||||
cors_config.AllowCredentials = true
|
cors_config.AllowCredentials = true
|
||||||
cors_config.ExposeHeaders = []string{"set-cookie"}
|
cors_config.ExposeHeaders = []string{"set-cookie"}
|
||||||
corsGroup.Use(cors.New(cors_config))
|
|
||||||
file, err := os.Open(os.Getenv(CONFIG_PATH_ENV_VAR))
|
file, err := os.Open(os.Getenv(CONFIG_PATH_ENV_VAR))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
@ -35,6 +34,11 @@ func main() {
|
|||||||
var config models.GlobalConfig
|
var config models.GlobalConfig
|
||||||
err = json.NewDecoder(file).Decode(&config)
|
err = json.NewDecoder(file).Decode(&config)
|
||||||
|
|
||||||
|
cors_config.AllowOriginFunc = func(origin string) bool {
|
||||||
|
return origin[len(origin)-len(config.Domain):] == config.Domain
|
||||||
|
}
|
||||||
|
|
||||||
|
corsGroup.Use(cors.New(cors_config))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user