We've an Angular 2/4 web app running on AWS S3 buckets. We wanted to allow any * 3rd party website to access it's assets viz. .css
, .js
, .images
etc.
The 3rd party website is supposed to embed a code like this:
<script src="http://angular2-4-app.domain/widget.js"></script>
The widget.js
file internally calls other assets viz. .css
, .js
, .images
etc.
For example:
var n=document.createElement("script");
n.setAttribute("type","text/javascript");
n.setAttribute("src","folder1/asset1.js");
n.async="async";
The green line represent the requests in which the assets are served back to the 3rd party website which is not happening currently.
The red line represent the requests in which the assets are not served back to the 3rd party website which is happening currently because of CORS issues.
We wanted to achieve the green line requests.
The CORS seems to be enabled on them from the AWS console:
We need a solution like CORS in node.js
What else is required to enable CORS in this case?