Aspnetcore: Blazor wasm base path should be configurable post publish

Created on 22 May 2020  Â·  5Comments  Â·  Source: dotnet/aspnetcore

Currently the only way I can find to set Blazor wasm base path is by editing index.html <base href="/thepath/" /> and then publish it.

If I change the base path in the generated index.html after publish, when running the app I will get an error:

Failed to find a valid digest in the ‘integrity’ attribute for resource ‘http://mydomain/app/mybwa/_framework/wasm/dotnet.3.2.0.js’ with computed SHA-256 integrity ‘blabla…’. The resource has been blocked.

Suppose I want to run 5 different instances of the same app in different folders (for example shared hosting), I need to edit index.html and publish five times.

Alternatively I can disable integrity check so I can freely edit index.html post publish, but I'm not sure about the side effects.

In ASP.Net Core we can set app.UsePathBase with a value from IConfiguration.

It would be good if blazor wasm can read base path from configuration too.

Or is there a way to recalculate the signature for integrity check? Or to exclude index.html from integrity check?

affected-few area-blazor blazor-wasm enhancement severity-minor

Most helpful comment

True. But then how do you expect to configure the base path in a static file if you cannot run any code in server?

All 5 comments

You can easily achieve this if you are hosting the blazor application in asp.net core application. With that, you can bypass index.html and configure a cshtml file where you can set base path in the you would like to.

@nvmkpk point taken, but then you need a server that can run executables. Would be nice if base path is configurable and the app runs on static file server.

True. But then how do you expect to configure the base path in a static file if you cannot run any code in server?

As I said in my original post, I can already do this by editing index.html with a text editor, changing the base href, and then deploy (copy to server), provided the BlazorCacheBootResources in csproj is set to false.

Another thing that I have tried: having appsettings.json containing base path as one of the config. But I couldn't find a way to update builder.HostEnvironment.BaseAddress in Program.Main because it is read only. Even if this is possible I'm not sure that I can edit appsettings.json post deploy without turning off integrity check.

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

Was this page helpful?
0 / 5 - 0 ratings