I create a plain laravel 8 project to test pwa by following https://infyom.com/blog/how-to-make-a-laravel-application-pwahttps://infyom.com/blog/how-to-make-a-laravel-application-pwa.
It works as expected When I run it via cmd with php artisan serve [ http://localhost/127.0.0.1:8000 ], showing Install btn in the right side of the URL but when I try to run it on apache [ http://localhost/projectname ] (I am using Xampp), The installation btn doesn't show. When i check it using Chrome Light House, it shows the following Two error messages
Web app manifest or service worker do not meet the installability requirements 1 reason
Service worker is the technology that enables your app to use many Progressive Web App features, such as offline, add to homescreen, and push notifications. With proper service worker and manifest implementations, browsers can proactively prompt users to add your app to their homescreen, which can lead to higher engagement. Learn more.
Failure reasonNo matching service worker detected. You may need to reload the page, or check that the scope of the service worker for the current page encloses the scope and start URL from the manifest.
&
Does not register a service worker that controls page and start_url
Can someone please explain why this happens or how can I fix this issue?
Thank U in advance.
Since it work correctly when running it on php artisan serve, hoping to see it run on apache servers as well.
CodePudding user response:
When you use apache it's configure your project as a vhost and without port. In order to use service workers need SSL cert on you domain. Also if you want work locale in Chrome you can enable your localhost adding by insecure origin as secure domains list, easiest way to test pwa, in my opnion, was using ngrok. I use ngrok my all project when need test pwa in dev env. Usefull links: