Why can I use "http://localhost:PORT" with CORS in Spaces?

January 24, 2018 751 views
Object Storage

Safari doesn't respect my wildcard rule in CORS but Firefox and Chrome do. None of the suggestions in this StackOverflow post helped either: https://stackoverflow.com/questions/16824661/cors-request-not-working-in-safari/39875236.

I feel like this could be remedied if Spaces was configured to allow a URL without a TLD.

1 Answer

Thanks for flagging this issue for us. It looks like the input validation in our control panel is a bit too strict here. As a work-around until this experience is improved, you can create CORs configurations for Spaces using the API for origins without a TLD. For example, using s3cmd you can run:

  • s3cmd setcors cors.xml s3://example-space

Where the contents of the cors.xml file contains your CORs configurations in XML format. For example:

<CORSConfiguration>
 <CORSRule>
   <AllowedOrigin>http://localhost:3000</AllowedOrigin>

   <AllowedMethod>PUT</AllowedMethod>
   <AllowedMethod>POST</AllowedMethod>
   <AllowedMethod>DELETE</AllowedMethod>

   <AllowedHeader>*</AllowedHeader>
 </CORSRule>
</CORSConfiguration>
s3cmd is a popular cross-platform command-line tool for managing S3 and S3-compatible object stores. This guide provides a quick reference to commands that are useful for managing DigitalOcean Spaces.
Have another answer? Share your knowledge.