Question

Access-Control-Expose-Headers: How to expose additional headers in spaces CDN?

Posted March 2, 2020 156 views
DigitalOcean Spaces

In order to download files from DigitalOcean Spaces CDN using xhr, I need to add a following CORS header to OPTIONS/GET responses: Access-Control-Expose-Headers: ETag, Content-Range. If I don’t do that, I get a similar error in my google chrome console: Refused to get unsafe header "etag" (see https://stackoverflow.com/questions/5822985/cross-domain-resource-sharing-get-refused-to-get-unsafe-header-etag-from-re).

Spaces CDN settings make it possible to allow additional request headers (Access-Control-Allow-Headers), but there’s no option to expose additional headers (Access-Control-Expose-Headers).

Since I’m using CloudFlare for DNS management, I worked around this issue by deploying a web worker that adds Access-Control-Expose-Headers: ETag, Content-Range to every response from spaces CDN but ideally this would be possible in spaces settings.

Has anybody run into this issue? Do you know if they have plans to add this setting?

0 answers
Submit an answer

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!