silviolleite / laravel-pwa

Looks like an app, feels like an app, but IS NOT an app.
MIT License
937 stars 152 forks source link

Laravel PWA: ServiceWorker registration failed: TypeError #34

Open LjuAdmir opened 4 years ago

LjuAdmir commented 4 years ago

For a company we I work for, I tried to deploy this project and I get this error in the console (url redacted): Laravel PWA: ServiceWorker registration failed: TypeError: "ServiceWorker script at https://<url>/serviceworker.js for scope https://<url>/ encountered an error during installation."

LjuAdmir commented 4 years ago

I figured out that the issue is the fact I'm deploying it all via cPanel and how everything is set up, apache doesn't server files from the /public/ root, I was wondering can the serviceworker.js be moved anywhere else?

albertmir commented 4 years ago

The error is with '/offline' path set in serviceworker.js:

var filesToCache = [ '/offline', ... ];

This happens because you have to set up a new route for /offline path in routes/web.php like this: Route::get('/offline', function () { return view('vendor/laravelpwa/offline'); });

shaileshdhandhukiya commented 1 year ago

I get this type error how ti fix this issue

Laravel PWA: ServiceWorker registration failed: DOMException: Failed to register a ServiceWorker for scope ('http://localhost/laravel/ez-store/') with script ('http://localhost/laravel/ez-store/public/serviceworker.js'): The path of the provided scope ('/laravel/ez-store/') is not under the max scope allowed ('/laravel/ez-store/public/'). Adjust the scope, move the Service Worker script, or use the Service-Worker-Allowed HTTP header to allow the scope.