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!
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.
Hi there,
The CORS preflight requests are often sent using the
OPTIONS
method, especially when performing a POST or PUT request from a browser. Make sure your CORS settings allow theOPTIONS
method. You can addOPTIONS
to your allowed methods in the DigitalOcean Spaces CORS configuration:Also check that you’re setting the correct headers in your request, especially
Content-Type
. Sometimes, a missing or incorrectContent-Type
can trigger CORS issues.In your case, you already have the content type set in the
params
:Besides that, make sure that the file type is correctly detected. If needed, explicitly set it to
multipart/form-data
in case of issues:You can also use your browser’s developer tools to see what the CORS preflight request (
OPTIONS
) and response look like. Check if the headers on the response allow the origin, methods, and other necessary headers.Make sure that your CORS settings on DigitalOcean Spaces allow the following headers:
Access-Control-Allow-Origin
:*
or the specific origins (http://localhost:5173
)Access-Control-Allow-Methods
: EnsureGET
,PUT
,POST
, andOPTIONS
are allowedAccess-Control-Allow-Headers
: If you’re sending custom headers, such asAuthorization
orContent-Type
, make sure they are allowed here as well.Once you’ve made these changes, try again, and let me know if the issue persists!
- Bobby