Open jberlyn opened 3 years ago
Looks like this may be related to #259.
There's a slight difference in how you might fix this compared to the previous routes.json file. With staticwebapp.config.json, the file no longer needs to be in the build output. What this means is that you don't need to place it in wwwroot. Instead, place it in the same folder as the Blazor app's csproj file (this should be the same folder that is set as your app_location
in the workflow file).
If staticwebapp.config.json isn't in wwwroot, you shouldn't need to modify offlineAssetsExclude
.
Fixing this might solve the other issues as well. I think the service worker cancelled the other requests because it couldn't download staticwebapp.config.json.
If staticwebapp.config.json isn't in wwwroot, you shouldn't need to modify offlineAssetsExclude.
I tried this couple of days back and it shows the same error above. My staticwebapp.config.json
is in the same directory as the Blazor app's .csproj file. Didn't verify if modifying offlineAssetsExclude
would resolve this issue.
@Zhiyuan-Amos This is surprising. Can you share the repo if it's public? Another thing to try is to remove the staticwebapp.config.json file completely just to see if the error still appears (it would be even more surprising if it's still a problem).
@anthonychu I've created PRs on my repository so that you can validate the behaviour on the deployed webpages:
staticwebapp.config.json
removed@anthonychu do you still need my PRs & the corresponding deployed webpages? :)
Any update to this? Has this been resolved? I moved away from Azure Static Web Apps since I created this issue.
The solution from @anthonychu worked for me.
After I moved the staticwebapp.config.json
from the wwwroot folder to the root of my Blazor project (using .NET 7) I'm able to install my PWA again, when using Azure Static Web Apps.
Describe the bug I have a Blazor WebAssembly application that is currently deployed to Azure Static Web Apps. I have setup my Blazor application as a PWA using the steps from the official Microsoft documentation.
https://docs.microsoft.com/en-us/aspnet/core/blazor/progressive-web-app?view=aspnetcore-5.0&tabs=visual-studio
When I run the deployed application, the service worker fails to start as it is unable to access certain resources of my Blazor application, as specified in the service worker assets file.
When I run my application locally with IIS, the service worker starts correctly and I am able to install the application as a PWA.
To Reproduce The application is deployed here: https://witty-pebble-0c280bc10-11.centralus.azurestaticapps.net/
As you can see, when you open it in Google Chrome (or another browser), the service worker fails to reach many resources such as files in my
_framework
folder, as well as thestaticwebapp.config.json
file.The app is deployed using the default GitHub actions build file when first setting up the static web app. The only different is that I have a staticwebapp.config.json file that contains the following:
Expected behavior The service worker should start and my user should be prompted to install the application.
Screenshots
Device info (if applicable):