CORS: add support for more parameters

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
Nicola Murino
2022-08-02 18:44:34 +02:00
parent 455bb550ee
commit fdc10aa6c7
10 changed files with 89 additions and 52 deletions

View File

@@ -57,13 +57,15 @@ func (s *webDavServer) listenAndServe(compressor *middleware.Compressor) error {
}
if s.config.Cors.Enabled {
c := cors.New(cors.Options{
AllowedOrigins: util.RemoveDuplicates(s.config.Cors.AllowedOrigins, true),
AllowedMethods: util.RemoveDuplicates(s.config.Cors.AllowedMethods, true),
AllowedHeaders: util.RemoveDuplicates(s.config.Cors.AllowedHeaders, true),
ExposedHeaders: util.RemoveDuplicates(s.config.Cors.ExposedHeaders, true),
MaxAge: s.config.Cors.MaxAge,
AllowCredentials: s.config.Cors.AllowCredentials,
OptionsPassthrough: true,
AllowedOrigins: util.RemoveDuplicates(s.config.Cors.AllowedOrigins, true),
AllowedMethods: util.RemoveDuplicates(s.config.Cors.AllowedMethods, true),
AllowedHeaders: util.RemoveDuplicates(s.config.Cors.AllowedHeaders, true),
ExposedHeaders: util.RemoveDuplicates(s.config.Cors.ExposedHeaders, true),
MaxAge: s.config.Cors.MaxAge,
AllowCredentials: s.config.Cors.AllowCredentials,
OptionsPassthrough: s.config.Cors.OptionsPassthrough,
OptionsSuccessStatus: s.config.Cors.OptionsSuccessStatus,
AllowPrivateNetwork: s.config.Cors.AllowPrivateNetwork,
})
handler = c.Handler(handler)
}