Viewers icon indicating copy to clipboard operation
Viewers copied to clipboard

Configuring server with requestOptions.auth function works only first time

Open thiagoss opened this issue 5 years ago • 2 comments

Before Creating an issue

  • Are you running the latest version?
  • Are you reporting to the correct repository?
  • Did you search existing issues?

Bug Report

Describe the Bug

Adding a server with a requestOptions.auth that is a function only works on the first load. Second time the page is loaded the requests are sent without the auth header.

What steps can we follow to reproduce the bug?

  1. Configure a server with an auth function to provide headers
  2. Load the page once, check that requests are made with authorization header
  3. Load it a second time, verify that the auth headers are not present anymore

:warning: Reports we cannot reproduce are at risk of being marked stale and closed. The more information you can provide, the more likely we are to look into and address your issue.

https://github.com/OHIF/Viewers/blob/2f443fa2efa223ac0fcdf238eee834c6a4ee3fc1/platform/core/src/redux/reducers/servers.js#L9

The ADD_SERVER reducer here does uniqueness check and keeps the one already in the store. Since the auth in this case is a function it is likely that it is not properly persisted (it is a function, how would it be persisted?) and a second page load fetches the local storage and the auth setting is not present. The code tries to ADD_SERVER again with the auth but this new entry gets ignored since it has the same id as before.

It should preserve or replace the requestOptions on the stored entry with the new information it receives.

thiagoss avatar Jul 21 '21 03:07 thiagoss

I tried modifying the order on ADD_SERVER just so that the newly added server would take precedence and replace but I'm at a loss on how to build and package it for testing within my application. I've just used yarn add to add the dependency and embedded the viewer in my react Material app.

Any tips on how to replace the npm repository version with my locally built component with my changes would help me debug and get past this. Thanks.

thiagoss avatar Jul 21 '21 03:07 thiagoss

Please review the latest code in the master branch. This issue might have been resolved. If it persists, kindly reopen the issue with updated details.

Try viewer-dev.ohif.org instead of viewer.ohif.org Our viewer.ohif.org is deployed from release branch while viewer-dev.ohif.org is our master branch Read more about branch explanations here https://docs.ohif.org/development/getting-started#developing

sedghi avatar Oct 13 '23 18:10 sedghi