I am using the Softlayer object storage and accessing my objects in the S3 bucket using SDK API from my Node.js application deployed on IBM Bluemix. I am able to insert the objects in the bucket but while accessing the object using SDK API I am getting the CORS error as below:
XMLHttpRequest cannot load https://s3-api.us-geo.objectstorage.softlayer.net/<my bucket-name>/<my object-name>. No. 'Access Control-......Allow-Origin' header is present on the requested source. Origin 'http://localhost:6009' is therefore not allowed.
In AWS S3, we can configure the properties at the bucket level and we can explicitly enable CORS but then I don't see any such option in Softlayer.
Please advise.
Please review the guides at https://ibm-public-cos.github.io/crs-docs/crs-operations.html
This is the official documentation for the Cloud Object Storage (S3) offering.
Object Storage uses standard S3 API and it seems you has chosen Object Storage S3 API so that you can use AWS SDK (php sdk in my case) to enable CORS and another policies at the bucket level.
That's how I did it:
$s3Client->putBucketCors([
'Bucket' => 'your-object-storage-bucket-name',
'CORSConfiguration' => [
'CORSRules' => [
[
'AllowedHeaders' => ['*'],
'AllowedMethods' => ['GET', 'POST', 'PUT', 'DELETE'],
'AllowedOrigins' => ['*'],
]
],
],
]);
Regarding IBM Softlayer: I reported this issue about 3 month ago and I asked for code samples but they didnt neither solve my problem nor provide a concrete reference, that's a pitty because the operator recommended I have to post this issue in stackoverflow and wait for IBM developers answers since they cant to communicate to them, so docs is poor and customer support is disappointing.
I hope this info help you.