CORS errors when requesting data from FHIR Repository with JavaScript / AJAX .
Hoping someone can help.
I had posted a similar question outside this group a while ago "Errors requesting data from local Ensemble FHIR Repository" but haven't had the chance to follow up on it since. It was suggested I re-post inside this group.
I'm trying to request data from my local FHIR repository using a simple JavaScript client and am getting the following CORS errors . ( It is a standalone client not inside HealthShare without CSP etc. on my localhost ).
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:57773/csp/healthshare/fhirserver/fhir/Patient. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).
This is what it's doing in essence ( see below ).
xhttp.open("GET", "http://localhost:57773/csp/healthshare/fhirserver/fhir/Patient", true);
xhttp.setRequestHeader("Content-type", "application/json+fhir");
xhttp.send();
If however I change the URL to public FHIR repo ( e.g. "http://spark.furore.com/fhir/Patient" ) I get a response ( FHIR Bundle etc. )
Do I have to configure the server response headers somewhere? I have the default FHIR respository setup outlined here :
http://localhost:57773/csp/docbook/DocBook.UI.Page.cls?KEY=FOVW_fhir#FOVW_fhir_svrcli
Please let me know how I can resolve this issue.
Thanks,
Conor