title: Amazon aws s3 and ec2 CORS for Full Stack web (angular 2/spring boot)
body: <p>Here is what I did:
  I created the front end using Angular 2, and created the backend code using Spring boot. Then in my front end code, I hard code my api address using EC2 address (which is in front end), and hard code my front end address (the S3 address) in Filter class in Spring boot to get rid the CORS issue. </p>
  
  <p>Then in my front end I run <code>ng build --prod</code> to get the deploy static files, in my backend I run <code>mvn package</code> to get the jar file. Upload the <code>jar</code> file to EC2 instance, it starts successfully for the backend part.</p>
  
  <p>Now upload all the static files into S3 storage, and run the S3 domain, I got following error:</p>
  
  <pre><code>Failed to load ec2-35-182-225-61.ca-central-1.compute.amazonaws.com:8080/api/refresh: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https. 
  </code></pre>
  
  <p>Is it have any tutorial that link front end and backend using S3 and EC2?</p>
  
  <p>Edit:
  After I added the CORS on S3 part by trichetriche's answer, I got new error</p>
  
  <pre><code>main.e4936af900574d09c368.bundle.js:1 ERROR DOMException: Failed to execute 'open' on 'XMLHttpRequest': Invalid URL
      at http://cloud.eatr.com.s3-website.ca-central-1.amazonaws.com/polyfills.b3f1cff0521ef8205be4.bundle.js:1:56874
      at XMLHttpRequest.o.(anonymous function) [as open] (http://cloud.eatr.com.s3-website.ca-central-1.amazonaws.com/polyfills.b3f1cff0521ef8205be4.bundle.js:1:20687)
      at t._subscribe (http://cloud.eatr.com.s3-website.ca-central-1.amazonaws.com/main.e4936af900574d09c368.bundle.js:1:424047)
      at t._trySubscribe (http://cloud.eatr.com.s3-website.ca-central-1.amazonaws.com/main.e4936af900574d09c368.bundle.js:1:7030)
      at t.subscribe (http://cloud.eatr.com.s3-website.ca-central-1.amazonaws.com/main.e4936af900574d09c368.bundle.js:1:6859)
      at e.a (http://cloud.eatr.com.s3-website.ca-central-1.amazonaws.com/main.e4936af900574d09c368.bundle.js:1:745892)
      at e._innerSub (http://cloud.eatr.com.s3-website.ca-central-1.amazonaws.com/main.e4936af900574d09c368.bundle.js:1:748287)
      at e._tryNext (http://cloud.eatr.com.s3-website.ca-central-1.amazonaws.com/main.e4936af900574d09c368.bundle.js:1:748211)
      at e._next (http://cloud.eatr.com.s3-website.ca-central-1.amazonaws.com/main.e4936af900574d09c368.bundle.js:1:748034)
      at e.next (http://cloud.eatr.com.s3-website.ca-central-1.amazonaws.com/main.e4936af900574d09c368.bundle.js:1:9365)
  </code></pre>