Nongnooch Roongpiboonsopit • almost 5 years ago
Unable to customize the prebuilt screen with searchNearMe or make any query using JavaScript SDK due to because a request is blocked by CORS policy
Hi, I am following instructions below to customize the prebuilt screens to land directly on the "Search Near Me" screen
https://docs.healthcarelocator.com/QStartGuide/Customize_the_prebuilt_screens_of_the_SDKs.htm?rhhlterm=configPatch&rhsyns=%20#Update_configuration_of_the_SDK_instance
However, I always getting CORs issue as shown below:
Access to XMLHttpRequest at 'https://api.healthcarelocator.com/api/graphql/query' from origin 'http://localhost:5000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
+++++++++++++++
I also tried downloading the latest JavaScript SDK package in
https://github.com/hcl-sdk/HealthCareLocatorWebSDK
and run a web example using 'npm run start-example-web' (using my apiKey) and encountered the same error when clicking on the 'Find a dentist near me' in the menu
I also tried running an example in the 'hcl-sdk-api' package (Service calls to get data without implementing UI) and encountered the same issue there as well.
********************
I am completely blocked at this point. Can someone please chime in or shed some light on this issue?
Thanks you so much!
Comments are closed.

3 comments
Chun-Hao Huang • almost 5 years ago
Yes, maybe it is because the URL (https://api.healthcarelocator.com/api/graphql/query) is only for the demo? Hence, it is very reasonable for the developers to not set the CORs policy for all domains and prevent the requests from malicious locations? (Or you should contact the organizer for further assistance)
If you are trying to get the healthcare providers' information, specifically pure json data, please turn to use hcl-sdk-api, which might not be obviously mentioned in the documentation but have an example demo code in the official GitHub repo (https://github.com/hcl-sdk/HealthCareLocatorWebSDK/blob/release%2F1.0.0/packages/hcl-sdk-api/test.html).
Nongnooch Roongpiboonsopit • almost 5 years ago
Thanks for promptly help looking into this, Chun-Hao! :)
I also downloaded an example you provided with my apiKey and spinned off a server to run the example but encounter the same CORS error... :(
https://github.com/hcl-sdk/HealthCareLocatorWebSDK/blob/release%2F1.0.0/packages/hcl-sdk-api/test.html
Have you successfully made a query either from the front-end (cdn) or server (nodejs) with the JavaScriptSDK?
Nongnooch Roongpiboonsopit • almost 5 years ago
Hi Chun-Hao, this issue seems to be resolved after I created a new account to receive a new apiKey. (Not sure what has been changed though)
Thanks for your help!