hello.
from react js i want to upload image directly to the digitalocean spaces without any server.
the frontend run on localhost 5173 port. and i already configured the cors for this port.
but its still gives me this issue.
here is my code
cors configuration:
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!
Hi there,
I think the CORS issue might be related to how Spaces handles the preflight OPTIONS
request when you’re uploading directly from the browser. From what I understand, you don’t actually set OPTIONS
explicitly in the Spaces CORS settings, it’s handled automatically if the real method you’re calling (like PUT
or POST
) is allowed.
A few things I’d still double‑check:
Make sure the Allowed Methods
list in Spaces includes the method you’re using for the upload (PUT
or POST
).
Confirm the origin (http://localhost:5173
) is added to the Allowed Origins
.
If you’re sending custom headers (like Authorization
or Content-Type
), make sure they’re in Allowed Headers
.
If those look fine, it might help to inspect the network tab in your browser’s dev tools to see exactly what headers the preflight request is sending and what the response from Spaces includes.
- 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.