404 Error when running published blazor-wasm project

Hi there,

I’m having an issue after publishing a blazor-wasm project - and I’m not sure if I am missing something with regards to the ServiceStack pre-rendering, or if it is something more general that I am missing. I hope you guys can help :frowning:

Steps to reproduce:

  1. Create a new blazor-wasm project

  2. Open the project and build

  3. right-click-publish the start-up folder (TestPublish in my case) and publish to a folder:

4.publish succeeds without errors:

  1. run the published exe (TestPublish.exe in my case). No errors in console on start-up

  2. navigating to https://localhost:5001 shows an error:

  3. reviewing the error console shows the following errors:


  4. taking a look at the Networking tab in the browser’s developer tools shows the following:


any ideas on what I’m missing here?

The pre-rendering tasks are performed by the included GitHub Actions, i.e. they wont be run when you publish a project, so either the Prerender Tasks will need to be run locally before publishing the project with the published package containing the content in the /prerender folder or the pre-render functionality would need to be removed from the template.

to run the prerender task, I need to run the “prerender” tests, am I right?

Like this:

dotnet test --filter TestCategory=prerender --logger:"console;verbosity=detailed"

Yep that should generate the pre-rendered pages, which would also need to be included in the bundled package

1 Like

makes sense - thank you :slight_smile:

1 Like

ok - one last issue… if I run the pre-render tests and ensure that the “prerender” folder is copied with the output when publishing, the 404 error disappears…however - these errors still persist:

the errors do not occur when running the app from Visual Studio…

This looks it’s calling its API using an incorrect host name, GitHub Actions publishes the project using the command:

Which tells it what DEPLOY_API and DEPLOY_CDN to use which executes these pre-publish tasks to update the necessary host names in the different configs:

If you’re not using a CDN you can omit /p:DEPLOY_CDN, but I’d execute the same publish tasks so the correct configuration is updated, otherwise you’d need to update them manually.

Or maybe it’s just that the ApiBaseUrl hasn’t been properly configured in your appsettings: