madskristensen / WebEssentials.AspNetCore.ServiceWorker

Other
339 stars 61 forks source link

errors after configuring pwa with WebEssentials.AspNetCore.PWA #79

Open Federico-Luna opened 4 years ago

Federico-Luna commented 4 years ago

Hello @madskristensen

I hope that you can help me. Thanks in advance.

I have configured my razor pages .net core 3.1 app to work as PWA following the steps indicated in: https://github.com/madskristensen/WebEssentials.AspNetCore.ServiceWorker

In step 4 the following errors come out: manifest.webmanifest: 1 GET https: // localhost: 44330 / manifest.webmanifest 404 manifest.webmanifest: 1 Manifest: Line: 1, column: 1, Syntax error. A bad HTTP response code (404) was received when fetching the script. (index): 1 Uncaught (in promise) TypeError: Failed to register a ServiceWorker for scope ('https: // localhost: 44330 /') with script ('https: // localhost: 44330 / serviceworker'): A bad HTTP response code (404) was received when fetching the script. manifest.webmanifest: 1 GET https: // localhost: 44330 / manifest.webmanifest 404 manifest.webmanifest: 1 Manifest: Line: 1, column: 1, Syntax error.

This is startup.cs ConfigurationService Method: ` public void ConfigureServices(IServiceCollection services) {

        services.AddRazorPages()
            .AddRazorRuntimeCompilation();

        services.AddProgressiveWebApp();

        services.AddDbContext<AppDbContext>(options =>
                options.UseSqlServer(Configuration.GetConnectionString("CnStr")));

        services.Configure<RouteOptions>(Options =>
        {
            Options.LowercaseUrls = true;
            Options.LowercaseQueryStrings = true;
        });
    }

` and this is the manifest.json in the wwwroot folder:

`

{ "name": "My PWA app", "short_name": "PWA app", "description": "My first PWA app", "icons": [ { "src": "/imgs/logo_192.png", "sizes": "192x192" }, { "src": "/imgs/logo_512.png", "sizes": "512x512" } ], "display": "standalone", "start_url": "/" } `

bb1769 commented 4 years ago

I had the same problem. Turns out the issue is not so much with 3.1 but with using the Razor option. Using the MVC option for the app allowed the manifest and service worker to come through. See this closed issue for more: https://github.com/madskristensen/WebEssentials.AspNetCore.ServiceWorker/issues/70