Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for JavaScript module path to handle app not being hosted at the root of the website #3

Merged
merged 2 commits into from
Feb 22, 2024

Conversation

victorperez2911
Copy link
Contributor

…rent from the WebSite Root (e.g. using the href attribute element of the index.html base element)

…rent from the WebSite Root (e.g. using the href attribute element of the index.html base element)

string path = new Uri(NavManager.BaseUri).AbsolutePath + "_content/Blazor.BroadcastChannel/Blazor.BroadcastChannel.js";

//_moduleTask = new(() => jsRuntime.InvokeAsync<IJSObjectReference>("import", "/_content/Blazor.BroadcastChannel/Blazor.BroadcastChannel.js"));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to comment out the code, you can just delete it 😉.

…stChannelService` class constructor and the adjustment of how the `path` variable is set. The `NavigationManager` parameter has been removed from the constructor of the `BroadcastChannelService` class. The `path` variable, which was previously set using the `BaseUri` property of the `NavigationManager` instance, is now directly set to a specific string.

Changes:
1. The `BroadcastChannelService` class constructor has been modified by removing the `NavigationManager` parameter. This change simplifies the constructor and removes the dependency on the `NavigationManager`.
2. The `path` variable setting has been changed. Instead of using the `BaseUri` property of the `NavigationManager` instance, it is now directly set to the string `./_content/Blazor.BroadcastChannel/Blazor.BroadcastChannel.js`. This change makes the `path` setting more straightforward and less dependent on other variables.
3. A commented out line of code that sets the `_moduleTask` variable has been removed. The `_moduleTask` is still set in the same way, but now it uses the `path` variable instead of a hardcoded string. This change makes the code cleaner and easier to understand.

References to the code changes can be found in the `BroadcastChannelService` class and the method where the `path` variable is set.
@tpeczek tpeczek changed the title Fix for calculating the Url Base in a wasm app served in a path diffe… Fix for JavaScript module path to handle app not being hosted at the root of the website Feb 22, 2024
@tpeczek tpeczek merged commit 6a47312 into tpeczek:main Feb 22, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error when using a Wasm App that is served from a different path than the root of the website
2 participants