Cross-domain request in Firefox to get DWA data into an OpenSocial gadget in RQM
The gadget runs correctly in IE, but when I run in Firefox I get the following error:
> Cross-Origin Request Blocked: The Same Origin Policy disallows reading
> the remote resource at https://<host>:8443/xxxx. (Reason: CORS header
> 'Access-Control-Allow-Origin' missing). <unknown> Cross-Origin Request
> Blocked: The Same Origin Policy disallows reading the remote resource
> at https://<host>:8443/xxxx. (Reason: CORS request failed). <unknown>
What could be the issue and what can I do? Is there anything I can do on the client side? Is DWA compatible with CORS (Cross-origin resource sharing)?
Thanks in advance!
One answer
https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy
If you are using Tomcat and would like to configure CORS, check out the answer in this post.
https://jazz.net/forum/questions/151485/does-rtc-support-cors-cross-origin-resource-needed-for-a-javascript-oslc-consumer
Comments
Thanks for the answer Donald.
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://<host>:<port>/jts/rootservices. (Reason: CORS header 'Access-Control-Allow-Origin' missing).
var rootServices = new XMLHttpRequest();rootServices.onreadystatechange = function(){if (rootServices.readyState == 4 && rootServices.status == 200){//do something}}rootServices.open('GET', 'https://<host>:<port>/jts/rootservices', true);rootServices.send(null);
Thanks for the answer Donald.
Have you checked the request/response headers? To make this work, you should have the response "Access-Control-Allow-Origin" header match the request "Origin" header.
Yes, I checked them with Advanced Rest Client Chrome extension and this is what I get:
Sorry dnong, but I have just realized that I see these response headers only when Allow-Control-Allow-Origin: * Chrome extension is enabled.
Have you been able to do this? IIRC, the "Access-Control-Allow-Origin" response header is returned by Tomcat (or whatever the application server), so using a Chrome extension is just a "hack". There should be no need for any extra settings on the client side.
Yes, finally I got it. The request I made from Javascript was wrong.
Thank you for all your assistance.