Tewr / BlazorWorker

Library for creating DotNet Web Worker threads/multithreading in Client side Blazor
MIT License
391 stars 36 forks source link

Cannot be initialized when not on `/` #84

Closed krauthaufen closed 2 years ago

krauthaufen commented 2 years ago

When hosting a published app in a sub-path the javascript init code is not found properly.

When hosting the app under http://a.com/test/index.html the worker-setup searches for its javascript in http://a.com/<…blazor…>.js

Tewr commented 2 years ago

Hello. Sounds like a bug. I should probably add the base path déclaration to all paths.

krauthaufen commented 2 years ago

Thank you for the quick response, is there any way to get the base-url apart from getting javascript's window.location?

Tewr commented 2 years ago

Well I'm not sure what the error is. So ove been reading the code and it looks like base path is already taken care of. I need more details. How are you setting up your solution? Did you change the href of the base tag ? To what value?

krauthaufen commented 2 years ago

Hey, I'm publishing my Project to a folder and don't know where it will be hosted in advance, so I'm not setting anything during build/publish. I'm also rather inexperienced with Blazor itself and use the whole thing from F# where there might be some tooling missing) and where I don't have any cshtmls or similar things. Basically my main.entry just sets up some HTML UI via directly evaluating javascript, etc. So I don't have a "base-tag" of any sort...

Maybe there's a way to programmatically set the required path but I'd need a hint how this works in standard-blazor apps. Thanks in advance and sorry for the confusing issue, I sometimes forget that there's a whole C# framework built around the things i use 😉

krauthaufen commented 2 years ago

Okay I just looked up the whole thing and maybe just creating a <base href="......." /> will solve the problem? At least as long as this works after loading the page initially without it my problem can be solved... I'll test that and get back to you once i have tested it, thanks for the tip

Tewr commented 2 years ago

I think this might be of interest to you: https://learn.microsoft.com/en-us/aspnet/core/blazor/host-and-deploy/?view=aspnetcore-5.0&tabs=visual-studio#app-base-path-1