mirror of
https://github.com/tinode/chat.git
synced 2025-03-14 10:05:07 +00:00
Merge pull request #909 from markeloff86/bugfix/cors-for-upload-api
CORS for media API
This commit is contained in:
@ -97,7 +97,7 @@ func matchCORSMethod(allowMethods []string, method string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// CORSHandler is the default CORS processor for use by media handlers.
|
||||
// CORSHandler is the default preflight OPTIONS processor for use by media handlers.
|
||||
func CORSHandler(req *http.Request, allowedOrigins []string, serve bool) (http.Header, int) {
|
||||
headers := map[string][]string{
|
||||
// Always add Vary because of possible intermediate caches.
|
||||
|
@ -151,13 +151,10 @@ func (ah *awshandler) Init(jsconf string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// Headers redirects GET, HEAD requests to the AWS server.
|
||||
// Headers redirects to the AWS server.
|
||||
func (ah *awshandler) Headers(req *http.Request, serve bool) (http.Header, int, error) {
|
||||
if req.Method == http.MethodPut || req.Method == http.MethodPost {
|
||||
return nil, 0, nil
|
||||
}
|
||||
|
||||
if headers, status := media.CORSHandler(req, ah.conf.CorsOrigins, serve); status != 0 {
|
||||
headers, status := media.CORSHandler(req, ah.conf.CorsOrigins, serve)
|
||||
if status != 0 || req.Method == http.MethodPost || req.Method == http.MethodPut {
|
||||
return headers, status, nil
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user