CORS defines a set of headers so a browser and server can interact to safely determine whether or not to allow the cross-origin request.
Today we are pleased to announce that we are putting live CORS support for our CDN service.
The new functionality enables our customers to set a value for the Access-Control-Allow-Origin header sent by the server so a container can be effectively enabled to use CORS.
The header can be set to an URL, to restrict the access to that origin, or to * to allow any origin.
There are three ways of enabling that header:
- Using the CDN Control section in Memset's Control Panel.
- Using Memset's API and the memstore.container.set_public_cdn method.
- Using standard OpenStack Object Storage API to set the container corsmetadata.
Let's see how to use OpenStack API to allow access to any origin to the public container. For this example we're going to use the official swiftcommand line client:
swift -U MYUSER -K MYPASSWORD \ -A https://auth.storage.memset.com/v1.0 post \ --meta cors:"*" \ public
In the example, MYUSER should be replaced by you admin user and MYPASSWORD by their password. The --meta option is used to set container's metadata, in this case, the content of cors, that will be used by the CDN nodes to populate the appropriate header.