Join 1M+ other developers and:
- Get help and share knowledge in Q&A
- Subscribe to topics of interest
- Get courses & tools that help you grow as a developer or small business owner
Access-Control-Expose-Headers: How to expose additional headers in spaces CDN?
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 (
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?
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.×