Add specific HTTP CORS headers
This commit is contained in:
parent
82513d6e54
commit
9fb7eec04b
1 changed files with 24 additions and 1 deletions
25
web/web.go
25
web/web.go
|
@ -45,7 +45,6 @@ func Setup(opts *cnf.Options) (err error) {
|
|||
s.Use(mw.Logs()) // Log requests
|
||||
s.Use(mw.Sock()) // Log requests
|
||||
s.Use(mw.Gzip()) // Gzip responses
|
||||
s.Use(mw.Cors()) // Add cors headers
|
||||
|
||||
// Add trace information
|
||||
|
||||
|
@ -55,6 +54,30 @@ func Setup(opts *cnf.Options) (err error) {
|
|||
|
||||
s.Use(auth())
|
||||
|
||||
// Add cors headers
|
||||
|
||||
s.Use(mw.Cors(&mw.CorsOpts{
|
||||
AllowedOrigin: "*",
|
||||
AllowedMethods: []string{
|
||||
"GET",
|
||||
"PUT",
|
||||
"POST",
|
||||
"PATCH",
|
||||
"DELETE",
|
||||
"TRACE",
|
||||
"OPTIONS",
|
||||
},
|
||||
AllowedHeaders: []string{
|
||||
"Accept",
|
||||
"Authorization",
|
||||
"Content-Type",
|
||||
"Origin",
|
||||
"NS",
|
||||
"DB",
|
||||
},
|
||||
AccessControlMaxAge: 600,
|
||||
}))
|
||||
|
||||
// Check body size
|
||||
|
||||
s.Use(mw.Size(&mw.SizeOpts{
|
||||
|
|
Loading…
Reference in a new issue