Openstack ‘Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present’

Did you just get error message ‘Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present‘?

This error might present itself when you are performing operations with SWIFT and your container doesn’t have the proper Access-Control-Allow-Origin metadata field set.

This may also occur if you deleted a container or a container was recreated. If such an event occured then the Access-Control-Allow-Origin metadata directive must be set again.

To do so use the the following command and replace the values your for your own.

Also, the below sets the Access-Control-Allow-Origin to * which means any host. For production environment you will want to restrict the Access-Control-Allow-Origin value to known hosts in order to avoid unauthorized uploads to your SWIFT containers.

curl -I -X POST -H 'X-Auth-Token: yoursecrettoken' -H 'X-Container-Meta-Access-Control-Allow-Origin: *' -H 'X-Container-Meta-Access-Expose-Headers: etag location x-timestamp x-trans-id Access-Control-Allow-Origin' https://your_endpoint_url/v1/AUTH_yourauth/yourcontainer_name