Change CORS to Cors on CLI options, specify origins as an option
This commit is contained in:
parent
b52394a166
commit
c3435e2ece
@ -80,7 +80,7 @@ func serveResult(result interface{}, err error, c *gin.Context) {
|
|||||||
func corsMiddleware() gin.HandlerFunc {
|
func corsMiddleware() gin.HandlerFunc {
|
||||||
return func(c *gin.Context) {
|
return func(c *gin.Context) {
|
||||||
c.Header("Access-Control-Allow-Methods", "GET, POST, OPTIONS")
|
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-Expose-Headers", "*")
|
||||||
|
c.Header("Access-Control-Allow-Origin", command.Opts.CorsOrigin)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ func SetupMiddlewares(group *gin.RouterGroup) {
|
|||||||
group.Use(requestInspectMiddleware())
|
group.Use(requestInspectMiddleware())
|
||||||
}
|
}
|
||||||
|
|
||||||
if command.Opts.CORS {
|
if command.Opts.Cors {
|
||||||
group.Use(corsMiddleware())
|
group.Use(corsMiddleware())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,8 @@ type Options struct {
|
|||||||
ConnectHeaders string `long:"connect-headers" description:"List of headers to pass to the connect backend"`
|
ConnectHeaders string `long:"connect-headers" description:"List of headers to pass to the connect backend"`
|
||||||
DisableConnectionIdleTimeout bool `long:"no-idle-timeout" description:"Disable connection idle timeout" default:"false"`
|
DisableConnectionIdleTimeout bool `long:"no-idle-timeout" description:"Disable connection idle timeout" default:"false"`
|
||||||
ConnectionIdleTimeout float64 `long:"idle-timeout" description:"Set connection idle timeout in minutes" default:"180"`
|
ConnectionIdleTimeout float64 `long:"idle-timeout" description:"Set connection idle timeout in minutes" default:"180"`
|
||||||
CORS bool `long:"cors" description:"Enable Cross-Origin Resource Sharing (CORS)" default:"false"`
|
Cors bool `long:"cors" description:"Enable Cross-Origin Resource Sharing (CORS)" default:"false"`
|
||||||
|
CorsOrigin string `long:"cors-origin" description:"Allowed CORS origins" default:"*"`
|
||||||
}
|
}
|
||||||
|
|
||||||
var Opts Options
|
var Opts Options
|
||||||
|
Loading…
x
Reference in New Issue
Block a user