Loading cross origin javascript file
-
Hi,
I am attempting to set a script tag on a report html recipe and experiencing a difficulty.
If both my website (hosting an iframe which the report is set to src of) and the jsreport server are the same domain I can use asset rendering like so
<script src="http://localhost:5488/assets/content/iframeResizer.contentWindow.min.js"></script>
However, if my website is on domain a, hosting a script file, and jsreport is hosted by IP, and the script tag is at the top of the recipe then the report does not render its content - it's completely blank (although the content is there)
If I move the script tag to the bottom of the recipe the content will render, but the script will not work
<script type="text/javascript" src="https://domain-a/iframeResizer.contentWindow.min.js" crossorigin="anonymous" />
Is there something particular with CORS script loading in JsReport that I'm not seeing in the config documentation?
-
could it be that your server is not handling CORS request correctly? jsreport by default has CORS enabled so i think the problem is not in jsreport, since you are loading content in an iframe with different host/ip then your server (the server that host your website) should contain some configuration that tells the browser that it is secure to render the content, this is specially true when executing remote scripts. what kind of server you are using for your website? maybe you just need to add some configuration that allows CORS in that level, but it depens in what technology are you using to host your website
-
Thanks @bjrmatos, we're using IIS and I haven't seen a difficulty before. Will continue to investigate
-
it can be a good idea to upload here an screenshoot that shows the error that you get in the browser, just to document the issue. maybe i can find some solution based on that too.