Add specific HTTP CORS headers

This commit is contained in:
Tobie Morgan Hitchcock 2017-11-16 20:46:54 +00:00
parent 82513d6e54
commit 9fb7eec04b

View file

@ -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{