Viewers icon indicating copy to clipboard operation
Viewers copied to clipboard

[Bug] Hosting with a custom baseUrl does not work

Open peerfunk opened this issue 1 year ago • 5 comments

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

peerfunk avatar May 16 '24 11:05 peerfunk

Could you provide the steps you followed to reproduce the issue?

sedghi avatar May 16 '24 17:05 sedghi

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

insinfo avatar May 16 '24 19:05 insinfo

Check this one https://docs.ohif.org/deployment/docker/#specifying-the-ohif-config-file

sedghi avatar May 16 '24 19:05 sedghi

Could you provide the steps you followed to reproduce the issue?

For building a Docker image:

  1. edit platform\app\package.json add PUBLIC_URL=/ohif/ APP_CONFIG=config/default.js to build:viewer
  2. edit Dockerfile add ENV and ARG PUBLIC_URL /ohif/ APP_CONFIG config/default.js
  3. edit platform\app\config\default.js set routerBasename to /ohif
  4. edit serve.json, add route base, like in the tutorial
  5. docker build --no-cache . -t ohif_custom_root
  6. 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!

peerfunk avatar May 17 '24 05:05 peerfunk

@sedghi

I did the following in order for docker to run with custom baseUrl

  1. PUBLIC_URL = /viewer/ and 2. app_config routerbasename= /viewer -> this is from the

  2. 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

  3. 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;

immahi79 avatar Sep 23 '24 18:09 immahi79

We just tried it and it worked fine.

sedghi avatar Dec 13 '24 14:12 sedghi