Viewers
Viewers copied to clipboard
[Bug] Hosting with a custom baseUrl does not work
Describe the Bug
Custom URL - non root BaseUrl does not work. Files other then index.html can only found in the root path. I tried a bunch of options, and checked if the past issue #2769 was resolved and it seems that in the code it is. I do not seem to find the issue.
Steps to Reproduce
I based my tries on this guide: https://docs.ohif.org/deployment/custom-url-access/ First I tried building a Docker image, which is a bit different from this guide, you have to add the env to the dockerfile. it resulted in a container that will host all the files. The index will be available from the custom url, all other js files only from the root directory. I then tried to build for production with pretty much the exact same commands as the guide, however I am on windows,so the guide is not accurate
The current behavior
hosting under a custom URL results in a blank page, the webbrowser is unable to load the js files
The expected behavior
I want to be able to host ohif under /ohif, the code should be writte in a way where a different baseUrl should not matter at all.
OS
Windows 10
Node version
18.18.2
Browser
Firefox 126.0
Could you provide the steps you followed to reproduce the issue?
Hosting with a custom baseUrl
I would also like to do this, it would be interesting if there was a docker image available that supports this
I didn't try to compile a version following the tutorial, as I'm not very familiar with node/react, I only work with Dart and AngularDart on a daily basis
Check this one https://docs.ohif.org/deployment/docker/#specifying-the-ohif-config-file
Could you provide the steps you followed to reproduce the issue?
For building a Docker image:
- edit platform\app\package.json add PUBLIC_URL=/ohif/ APP_CONFIG=config/default.js to build:viewer
- edit Dockerfile add ENV and ARG PUBLIC_URL /ohif/ APP_CONFIG config/default.js
- edit platform\app\config\default.js set routerBasename to /ohif
- edit serve.json, add route base, like in the tutorial
- docker build --no-cache . -t ohif_custom_root
- docker run ohif_custom_root -p 80:80 This somehow does not work on my windows pc it only works on linux. On windows I get multiple errors while building in several tsx files ERROR in ../../../extensions/default/src/getCustomizationModule.tsx 3:0-83. I used docker build on this windows machine with an older version of the repo last August and it worked. I can however run the linux built image on the windows pc just fine (but with the incorrect root paths).
For running with npx: Pretty much the sames steps, I just also set the windows env for PUBLIC_URL and APP_CONFIG before building similar to this:
$env:PUBLIC_URL="/ohif/" $env:APP_CONFIG="config/ohif.js" yarn build npx serve -c ./public/serve.json //see tutorial on how to run it
I know that I set the variables twice, I just wanted to make sure not to miss something.
Hope this helps at least a little bit. Thank you for your interest!
@sedghi
I did the following in order for docker to run with custom baseUrl
-
PUBLIC_URL = /viewer/ and 2. app_config routerbasename= /viewer -> this is from the
-
in the Docker file changed the reference from copy to the custom directory +COPY --from=builder /usr/src/app/platform/app/dist /usr/share/nginx/html/viewer
-
Updated the below line in .docker/Viewer-v3.x/default.conf.template to refer the index from /viewer custom directory try_files $uri $uri/ /viewer/index.html;
We just tried it and it worked fine.