ekolis
ekolis

Reputation: 6786

Deploying Blazor PWA to server folder, I get errors saying that various files cannot be found

I can deploy to the root of a server (e.g. http://localhost:8008) but I can't deploy to a subfolder (e.g. http://edkolis.com/pwaexperiment/wwwroot/index.html); I get errors loading various files when I try that. Files that are missing include app.css and blazor.webassembly.js:

<link href="css/app.css" rel="stylesheet" />
<script src="_framework/blazor.webassembly.js"></script>

I see there is a <base> tag in the index.html that specifies that all relative URLs should point to the server root:

<base href="/" />

however if I remove this tag I still get the same errors. How can I deploy my Blazor PWA to a subfolder and have it work, and yet also have it work at the root for local testing (i.e. I don't want to hardcode a server URL into the <base> tag)?

Upvotes: 2

Views: 429

Answers (1)

rdmptn
rdmptn

Reputation: 5601

The base href must match the actual path you deploy to.

To avoid changing it build-time, update the launchsettings JSON with that folder name so local (dev) runs also use the"production" base path

Upvotes: 2

Related Questions