Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expressjs example is not working in launch.smarthealthit.org #115

Open
QusaiAnthem opened this issue Feb 12, 2021 · 4 comments
Open

Expressjs example is not working in launch.smarthealthit.org #115

QusaiAnthem opened this issue Feb 12, 2021 · 4 comments

Comments

@QusaiAnthem
Copy link

QusaiAnthem commented Feb 12, 2021

We are trying to use the Expressjs example in here: https://codesandbox.io/s/c0che provided by @vlad-ignatov as a starting point to build a SoF application in our team at Anthem. We are facing an issue with the launching of the Example app using the launch.smarthealthit.org:

Steps:

Expected out put: browser to show a patient JSON object
Actual: The /launch path get executed but when the we are redirected to the /app path it gets stuck in pending for a bit and fails to load any things. Also, the nodejs server logs the following error:
image

To make it work, repeat the steps above but with "Simulate launch within the EHR user interface" being unchecked. The app launches without errors and shows the Patient JSON in the browser, see below:
image

We did debugging by putting break points in the code. In the case of failure, the express sessionID is different for the /launch and /app handlers. So, the ready method is not recognizing the launch state and shows the "Error: No state found! Please (re)launch the app" error as shown in the screenshot above. We suspected that it might relate to the application being rendered in an iframe (by keeping "Simulate launch within the EHR user interface" unchecked). We tried to set X-Frame-Options header to allow the response content to be rendered in an iframe but we got no success with that.

May anyone help out please?

Thank you

@vlad-ignatov
Copy link
Collaborator

Thank you for helping me realize that all of my server examples are somehow broken in a similar way (despite being frozen). In my case, it turns out that CodeSandbox is doing some weird routing now, making it impossible to properly resolve relative redirect URLs like "/app" to absolute ones on the same domain (which in turn messes up the cookies and the session). I have that fixed now.

As for your case:

  1. This is a standalone launch example. To use it in EHR launches, please remove the iss option from smartSettings.
  2. Can you check (at runtime) if your launch and redirect urls are using the same origin. If not, try to use full URL in the redirectUri option and see if that helps.

@QusaiAnthem
Copy link
Author

No problem and thank you for following up. I tried both options:

  1. I got this from the example code comments and tried this before. I just tried again but no success
  2. The origin is the same. I tried to put the full URL but with no success.

I tried to look at the Launcher code here (https://github.com/smart-on-fhir/smart-launcher) to find some hints or so but I am still in the find.

@QusaiAnthem
Copy link
Author

QusaiAnthem commented Feb 16, 2021

@vlad-ignatov do you have a nodejs example that works fine as "EHR launch" with "Simulate launch within the EHR user interface" checked?

@mfs-abhinav
Copy link

@vlad-ignatov do you have any update on above issue? We are getting the exact same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants