Embedding viewer into blazor-server app

Hi, we are currently developing a dotnet blazor-server app and would like to host the ohif viewer using static file hosting in kestrel on /ohif to serve indidual images from the main app.

I have been following the guides on your docs for setting the routerBasename: ‘/ohif’, and setting the env variable: export PUBLIC_URL=/ohif/

This does resolve most of the errors, but it still does not load with the following files returning 404:

Also it seems running yarn build a second times does nothing until I delete the whole repo and pull it again and start from scratch, even yarn clean:deep does not work, it never builds the dist folder again.

Any help here would be much appreciated :slight_smile:

I’ve encountered a similar issue when running yarn run build before. But it seems to be resolved by running yarn run start afterwards. I’m not quite sure about the reason for this problem.

For the issue, i think it maybe relate to the building process, if you setting PUBLIC_URL = /ohif/, the index.html under the dist directory will contains <script defer src="/ohif/app.js"></script> or window.PUBLIC_URL='/ohif/'. Make sure they are exists.

1 Like

Thank you so much :slight_smile:

It does seems like the public url is incorrect:

Can you share with me the terminal and commands you use to build it for production please?
I have been using git bash, and the following commands:

  • yarn config set workspaces-experimental true
  • yarn install
  • export PUBLIC_URL=/ohif/ yarn build

I also tried yarn build:ci which one time seemed to work better for setting the correct URLs, except what you see above.

Actually, I’m not sure what caused this issue. Perhaps you should open an issue on GitHub to discuss it. :slightly_smiling_face:
For me, after running yarn run build , I tried starting the project with yarn run start , and it somehow produced the correct result in the dist folder. It doesn’t make much sense, but it actually worked. :unamused: :face_exhaling:

1 Like

Thank you so much :slight_smile: I will start from scratch and try to do that and see what I get.
Do you use bash or powershell?

And I will try and make an issue if that does not work.
Really appreciate your help :slight_smile: