By St80ene
I deployed my React.js + Adonis.js app to Digital Ocean Spaces, but I’m running into a CORS error when trying to access files from my app.
If I copy the file URL and paste it into a new browser tab, the file loads successfully.
However, when trying to fetch it from my app, I get a CORS error in the console.
The same code worked perfectly on AWS S3 without any CORS issues. Here’s an example of the error: Access to fetch at ‘<DigitalOcean_Spaces_URL>/file_directory/<file>.pdf’ from origin ‘<my_app_URL>’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.
I have followed Digital Ocean’s documentation on setting CORS permissions, but the issue persists.
Has anyone encountered this before? Any ideas on how to resolve it?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hey there 👋
Even though the files load fine when accessed directly in the browser, browsers will block JavaScript-based requests (like fetch()
or axios
) unless CORS is properly configured.
Head over to your Space → Settings → CORS Configurations and make sure you’ve added your domain correctly there?
Don’t forget to include the full URL with https://
if you’re using SSL, it’s required for the CORS rule to work properly.
If you can, feel free to share a screenshot of your current CORS config, happy to take a look and help you troubleshoot!
- Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.