CORS Issue Ionic Framework upload to Amazon S3

I am trying to upload images to Amazon S3 using ionic via ionic serve. But i keep getting the error of

No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://localhost:8100’ is therefore not allowed access. The response had HTTP status code 403.

How do i get this sorted out. I have already tried the example given in this link but it doesnt work still has the same error.

Any help is appreciated.


Try running chrome with --disable-web-security as a parameter.

while this might work? i doubt it is a safe or good fix. what happens for other browsers??

Have a shortcut with this parameter on and it will work fine for testing.

If you are deploying this to a phone, you won’t have this issue.

i am not deploying to a phone and this is not for testing, this is for a production site.

Remember that CORS has to do with the resource you are trying to access. In this case the S3 bucket. You need to set the CORS policy on the bucket you are trying to access. Here is how to do it.

Obviously set the CORS policy as you require it