Viewers icon indicating copy to clipboard operation
Viewers copied to clipboard

[Bug] Setting token in url removes/ignores router base path

Open timriley-io opened this issue 1 year ago • 4 comments

Describe the Bug

When using a token in the url search params, the logic in the ModeRoute component that strips the token out of the url ignores that the application may be served from a path other than /.

I believe location.pathname could be replaced with window.location.pathname to yield the correct result.

Steps to Reproduce

  1. Set routerBasename in platform/app/public/config/default.js to /my-viewer
  2. yarn dev and open browser to OHIF viewer (http://localhost:3000/my-viewer)
  3. Open any study in the Basic Viewer
  4. Append &token=123 to the url
  5. Url will now be http://localhost:3000/viewer?StudyInstanceUIDs..., note that /my-viewer is no longer present!

The current behavior

When a token is supplied in the url, the page is redirected to a url that ignores the router base path. e.g. http://localhost:3000/my-viewer?token=123 redirects to http://localhost:3000 instead of http://localhost:3000/my-viewer

The expected behavior

When a token is supplied in the url, the application should continue to honour the base path of the router.

OS

macOS 13.4 (m1)

Node version

20.9.0

Browser

Chrome 120.0.6099.216 arm64

timriley-io avatar Feb 12 '24 10:02 timriley-io

cannot reproduce in 3.8.

my setup is to use /ohif as the routerBaseName

i did

  1. open /ohif/dicomjson?url=theurl&token=123
  2. ohif will refresh with new URL without token
  3. ohif will append auth token on downloading

beavermml avatar Feb 16 '24 16:02 beavermml

@beavermml - after your step 3, did the url still contain /ohif?

timriley-io avatar Feb 19 '24 05:02 timriley-io

@beavermml - after your step 3, did the url still contain /ohif?

Yes. The url still the same

beavermml avatar Feb 19 '24 05:02 beavermml

I'm having the same issue, I'm using /ohif RouterBaseName.

yomarbuzz avatar Feb 23 '24 15:02 yomarbuzz

Hi,

I'm actually having the same issue on one of our setups.

When we build a custom OHIF Docker image that will be served at /ohif/, we add PUBLIC_URL=/ohif/ before yarn run build and add routerBasename = '/ohif', we can then pass &token=... in the url and everything works fine.

However, when we build the OHIF orthanc plugin, we leave PUBLIC_URL=./ because we actually don't know where OHIF will be served, it will be served at http://localhost:8042/ohif/ if Orthanc is running standalone but, if Orthanc is running behind a reverse proxy, OHIF will be served at something like http://mydomain/orthanc/ohif/. Although we set the routerBasename correctly dynamically when loading the OHIF code, at some point, the url goes up one level when OHIF extracts the token and the remaining part of the OHIF files can not be loaded:

image

I have just implemented a ugly hack in the orthanc plugin to patch OHIF code on the fly according to @timriley-io suggestion: replace location.pathname by window.location.pathname and it seems to work. However, since I'm not familiar with react and/or react router and OHIF development in general, I'm not confident to submit this patch into OHIF code. Could someone from OHIF have a look at it ?

Thanks !

amazy avatar Mar 14 '24 09:03 amazy

hi all, is this an issue that is happening recently or it was there from start?

sedghi avatar Mar 15 '24 14:03 sedghi

I think the solution suggested makes sense, i will create a PR

Thanks!

sedghi avatar Mar 15 '24 14:03 sedghi

Hi @sedghi

This is actually here from the start.

Thanks for taking care of the PR !

amazy avatar Mar 15 '24 14:03 amazy

We just release the OHIF 3.8, you can find more details here https://ohif.org/release-notes/3p8/ If you still encounter this issue in 3.8, please re-open this.

sedghi avatar May 01 '24 17:05 sedghi