// blog
Testing a Browser DICOM Viewer Against Orthanc and dcm4chee: Six Things That Broke
To test a browser DICOM viewer against real archives, run Orthanc (with its DICOMweb plugin) and dcm4chee in Docker behind https, load sample studies with STOW-RS and drive the viewer with Playwright. What broke for us: Chrome’s Local Network Access prompt for a PACS on a local address, a doubled CORS header in front of dcm4chee (which sends its own), Orthanc refusing the password-less CORS pre-check, Keycloak tokens without the archive’s role, and DCMTK’s storescu refusing compressed files without extra options. Single sign-on works with the authorization code flow and PKCE in a popup.

Our DICOM viewer can open studies from a PACS. Its tests ran against a mock archive and a public one. Before telling anyone “it works with Orthanc and dcm4chee”, we ran both and tried.
The setup
- Docker on a Mac: Colima, a small Docker runtime from Homebrew.
- Orthanc 26.11 with its DICOMweb plugin and a login.
- dcm4chee 5.35, twice: unsecured, and secured with Keycloak, as in dcm4chee’s own guide. That’s an LDAP server, a database, the archive and Keycloak.
- nginx in front, for https, the way a clinic would serve it.
- 129 sample files: a JPEG lossless CT series, a JPEG 2000 MRI series, X-rays, ultrasound.
- Playwright drives the live viewer: connect, search, open a series, look at the image.
What broke
1. Chrome refused to ask the PACS at all. “Permission was denied for this request to access the loopback address space.” Since Chrome 142, a public website needs the user’s permission to reach a local network or the same computer. A clinic PACS on 10.x or 192.168.x gets the same prompt. To the page, a refusal looks like a server that doesn’t answer, so the viewer now says when the address is local and how to allow it.
2. dcm4chee failed CORS, with the same proxy lines that worked for Orthanc. dcm4chee answers CORS itself. With our lines added, the response carried two Access-Control-Allow-Origin headers, and a browser refuses that. Fix: in front of dcm4chee, add https and nothing else.
3. Orthanc needs the proxy to answer the pre-check. The browser’s OPTIONS request goes without the password, and Orthanc refuses requests without it. The proxy answers OPTIONS itself, then passes the real requests through.
4. A valid Keycloak token was “invalid”. dcm4chee said invalid_token for a token from Keycloak’s admin tool. That token had no realm roles; one from dcm4chee’s own client, with the user role, worked at once. A client registered for the viewer gets the roles too.
5. Keycloak’s address inside Docker. The browser signs in at localhost:8843, the archive checks tokens at keycloak:8843. dcm4chee’s guide covers it: a fixed public address for the browser, and KC_HOSTNAME_BACKCHANNEL_DYNAMIC for the archive.
6. DCMTK’s storescu wouldn’t send compressed files. By default it offers the archive only uncompressed transfer, then can’t convert JPEG lossless. Uploading with DICOMweb STOW-RS keeps each file exactly as it is.
Single sign-on, in 200 lines
The viewer now signs in to Keycloak, or another OpenID provider, as a public client:
- It reads the provider’s
.well-known/openid-configuration. - It opens a popup with the authorization code flow and PKCE (S256). The popup is opened in the click itself, or the browser blocks it.
- The code comes back in the URL fragment, which never reaches a server log. The popup lands on the viewer’s own page, hands the result over a
BroadcastChanneland closes. - The code is exchanged for tokens, kept in memory only. They’re renewed 30 seconds before they run out, once for all the requests waiting.
We shortened Keycloak’s token life to 60 seconds and searched after 45: the viewer renewed the token and the search went through.
The viewer embedded in another website signs in too. There the frame’s storage is partitioned by the website around it, so the popup’s BroadcastChannel message never reaches the frame. The popup also posts the result straight to its opener, which is the frame. Both the tool page and the frame use one redirect address, so IT registers one.
The result
| Archive | Sign-in | Opened |
|---|---|---|
| Orthanc 26.11 | user name and password | 92-image CT, JPEG lossless |
| dcm4chee 5.35 | none | 25-image MRI, JPEG 2000 |
| dcm4chee 5.35, secured | Keycloak | the same CT |
A wrong password says “The PACS refused the user name or password.” The automated tests grew by 16 checks, for the sign-in, the renewal and the local addresses.
Need imaging connected to your own archive, with your sign-in and your access rules? Tell me about it.
Frequently asked questions
Does Orthanc need CORS for a browser viewer on another site?
Yes. Orthanc has no CORS setting, so a reverse proxy in front of it adds the headers, and answers the OPTIONS pre-check itself, because that request comes without the password.
And dcm4chee?
No. dcm4chee answers CORS itself (Access-Control-Allow-Origin: *, with Authorization allowed). Adding your own header in a proxy sends two, and the browser refuses the answer.
Why does Chrome ask about the local network?
Since Chrome 142, a public website must get the user's permission before it reaches a local network or loopback address. A refused or unanswered prompt looks to the page like a server that doesn't answer, so the viewer now says so when the PACS address is local.
How does the viewer sign in to a Keycloak-secured dcm4chee?
As a public OpenID Connect client: the authorization code flow with PKCE in a popup, the code returned in the URL fragment, tokens kept in memory and renewed with the refresh token 30 seconds before they run out.
































































































































