Change CORS to Cors on CLI options, specify origins as an option

This commit is contained in:
Dan Sosedoff
2017-11-16 22:10:14 -06:00
parent b52394a166
commit c3435e2ece
3 changed files with 4 additions and 3 deletions

View File

@@ -80,7 +80,7 @@ func serveResult(result interface{}, err error, c *gin.Context) {
func corsMiddleware() gin.HandlerFunc {
return func(c *gin.Context) {
c.Header("Access-Control-Allow-Methods", "GET, POST, OPTIONS")
c.Header("Access-Control-Allow-Origin", "*")
c.Header("Access-Control-Expose-Headers", "*")
c.Header("Access-Control-Allow-Origin", command.Opts.CorsOrigin)
}
}

View File

@@ -10,7 +10,7 @@ func SetupMiddlewares(group *gin.RouterGroup) {
group.Use(requestInspectMiddleware())
}
if command.Opts.CORS {
if command.Opts.Cors {
group.Use(corsMiddleware())
}