smart-on-fhir / client-js

JavaScript client for FHIR
Other
288 stars 209 forks source link

Uncaught (in promise) Error: Failed to fetch the conformance statement from "https://staging-fhir.ecwcloud.com/fhir/r4/FFBJCD/metadata". TypeError: Network request failed #167

Closed msohaib308 closed 1 week ago

msohaib308 commented 1 year ago

I am having XML response issue

fhirClient is expecting JSON format but fhir server is returning XML here is the fhir server URLs

https://staging-fhir.ecwcloud.com/fhir/r4/FFBJCD/metadata https://staging-fhir.ecwcloud.com/fhir/r4/FFBJCD/.well-known/smart-configuration

Fhir server provide extra query parameter "_format=json" to get JSON response, this option is only for metadata but they did not provide this option for "smart-configuration" end point

I don't know how to set this ("_format=json" ) configuration in fhirCLient Library.

https://staging-fhir.ecwcloud.com/fhir/r4/FFBJCD/metadata?_format=json

Screenshot 2023-03-31 124304

Is there any option to accept XML responses

vlad-ignatov commented 1 year ago

The client does NOT support XML but it sends and accept: application/json header on each request to tell the server how to respond. This seems to work fine with your server.

As the screenshot shows, the problem is not there. You just need to configure / modify your FHIR server to support CORS.

msohaib308 commented 1 year ago

Issue is the XML response type

Anyway if i can handle on client side Because FHIR server is owned by third party

vlad-ignatov commented 1 year ago

If you try loading those URLs in a browser window you will get back XML. That is because browsers send some accept headers by default. Otherwise you would get JSON, even if you don't send any accept header. Don't let that trick you into thinking that XML is the issue - in this case what you see is not what you get :)

Every FHIR server MUST support CORS. Otherwise it would be unusable (even if you didn't need to authenticate). You can't work around this from the client side and that is exactly the point of CORS - clients should be rejected unless server admins say they shouldn't.

Your only choice is to let them know that CORS must be enabled and perhaps send them that screenshot for reference.

zamananjum0 commented 11 months ago

Is this resolve? @msohaib308 Can you please guide me on this?

msohaib308 commented 11 months ago

Hy @zamananjum0

Issue is not resolved yet however they suggested to try implementation on backend side Below is the email that i got from ECW Team

image

vincehartman38 commented 2 months ago

Did the 21st Century Act require SMART on FHIR apps by EHRs for EHR-launch require it to be browser-based? Like is this allowable behavior that eCW can argue CORS whitelisting as an "enhancement request" if @vlad-ignatov is stating it's a requirement for SMART on FHIR to function and push us to do (3). @msohaib308 - how did you end up resolving this?

vlad-ignatov commented 1 week ago

I see that they have added CORS now, so this can be closed.