Hi, I’ve been trying to setup an object storage bucket with Lightsail, but I can’t find any mentions/docs/ways to configure CORS policies like what’s possible on normal S3 buckets (the JSON/XML formatted one). I’m developing my app locally and trying to upload files to the bucket from the app with the created access key, and got blocked by the (usual) CORS error:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://mybucket.s3.ap-southeast-1.amazonaws.com/. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://mybucket.s3.ap-southeast-1.amazonaws.com/. (Reason: CORS request did not succeed).
Is it not possible to configure CORS policies at the moment? I can’t find any resources online regarding this, maybe since the service is just recently launched. Any help is hugely appreciated, thanks!
You are correct that Lightsail Object Storage does not currently expose a Configure CORS Policy type API. If you need CORS for your use case, such as an SPA without any backend, then you will be best served by using Native S3 instead. Having said that, the product ream is aware of your post as a signal that our customers may value a CORS feature.
If your application will have a server side component, then you will be able to programmatically access your Lightsail object storage from there. If the instance is a Lightsail instance, best practice is to use the Lightsail API SetResourceAccessForBucket as instances leverage temporary credentials they automatically rotate. Otherwise, the bucket access key should also work in such a scenario.