fix: need to create custom cors middleware instance for tus

This commit is contained in:
Derrick Hammer 2024-02-03 19:55:32 -05:00
parent 6894cd7e54
commit 5784afe064
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 16 additions and 1 deletions

View File

@ -199,8 +199,23 @@ func BuildS5TusApi(identity ed25519.PrivateKey, accounts *account.AccountService
}) })
} }
corsMiddleware :=
cors.New(cors.Options{
AllowedOrigins: []string{"*"},
AllowedMethods: []string{"GET", "POST", "PATCH", "DELETE", "HEAD", "OPTIONS"},
AllowedHeaders: []string{
"Upload-Offset",
"X-Requested-With",
"Tus-Version",
"Tus-Resumable",
"Tus-Extension",
"Tus-Max-Size",
"X-HTTP-Method-Override"},
AllowCredentials: true,
})
// Apply the middlewares to the tusJapeHandler // Apply the middlewares to the tusJapeHandler
tusHandler := middleware.ApplyMiddlewares(tusJapeHandler, cors.Default().Handler, middleware.AuthMiddleware(identity, accounts), injectJwt, protocolMiddleware, stripPrefix, middleware.ProxyMiddleware) tusHandler := middleware.ApplyMiddlewares(tusJapeHandler, corsMiddleware.Handler, middleware.AuthMiddleware(identity, accounts), injectJwt, protocolMiddleware, stripPrefix, middleware.ProxyMiddleware)
return tusHandler return tusHandler
} }