fix media download CORS headers
This commit is contained in:
+11
-10
@@ -225,10 +225,9 @@ func (oh *ossHandler) Headers(tenantID types.TenantID, method string, url *url.U
|
|||||||
}
|
}
|
||||||
|
|
||||||
if fdef.ETag != "" && strings.Trim(headers.Get("If-None-Match"), "\"") == fdef.ETag {
|
if fdef.ETag != "" && strings.Trim(headers.Get("If-None-Match"), "\"") == fdef.ETag {
|
||||||
return http.Header{
|
headers.Set("ETag", `"`+fdef.ETag+`"`)
|
||||||
"ETag": {`"` + fdef.ETag + `"`},
|
headers.Set("Cache-Control", oh.conf.CacheControl)
|
||||||
"Cache-Control": {oh.conf.CacheControl},
|
return headers, http.StatusNotModified, nil
|
||||||
}, http.StatusNotModified, nil
|
|
||||||
}
|
}
|
||||||
objectKey, err := oh.resolveObjectKey(fdef.Location)
|
objectKey, err := oh.resolveObjectKey(fdef.Location)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -253,12 +252,14 @@ func (oh *ossHandler) Headers(tenantID types.TenantID, method string, url *url.U
|
|||||||
}
|
}
|
||||||
|
|
||||||
if redirURL != "" {
|
if redirURL != "" {
|
||||||
return http.Header{
|
// Keep the CORS and Vary headers produced above. Replacing the map here
|
||||||
"Location": {normalizeSignedRedirectURL(redirURL)},
|
// makes preflight succeed but causes the actual browser GET to fail with
|
||||||
"ETag": {`"` + fdef.ETag + `"`},
|
// MissingAllowOriginHeader before it can follow the signed OSS redirect.
|
||||||
"Content-Type": {"application/json; charset=utf-8"},
|
headers.Set("Location", normalizeSignedRedirectURL(redirURL))
|
||||||
"Cache-Control": {oh.conf.CacheControl},
|
headers.Set("ETag", `"`+fdef.ETag+`"`)
|
||||||
}, http.StatusFound, nil
|
headers.Set("Content-Type", "application/json; charset=utf-8")
|
||||||
|
headers.Set("Cache-Control", oh.conf.CacheControl)
|
||||||
|
return headers, http.StatusFound, nil
|
||||||
}
|
}
|
||||||
return nil, 0, nil
|
return nil, 0, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user