Use service worker on localhost
See original GitHub issueCurrent Build Setup serve from http://localhost:8080/
but in entry-server.js
is
// service worker
if ('https:' === location.protocol && navigator.serviceWorker) {
navigator.serviceWorker.register('/service-worker.js')
}
There is problem with 'https:' === location.protocol
on localhost.
Is this check really needed? It introduce unnecessary complexity of need serving from https
on localhost. If you remove this check and run on http
not on localhost it will simple throw an error - for me this should be expected behaviour (developer will easily spot this problem) .
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Options for testing service workers via HTTP - Stack Overflow
I want to test service workers but I have a virtual host setup and I can't seem to be able to enable https...
Read more >Using Service Workers - Web APIs | MDN
A service worker functions like a proxy server, allowing you to modify requests and responses replacing them with items from its own cache....
Read more >Register Service Workers in Chrome during the development ...
Service workers are a handy tool, basically, a JavaScript file that runs separately from the main browser thread. It can be used for...
Read more >Getting an Angular PWA service worker installed on localhost
Service workers are meant to run on production builds over https. But we want to test on localhost.
Read more >Improving the service worker development experience
# Service worker development aids · Open a private browsing window. · Navigate to a page that registers a service worker. · Verify...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
And on localhost without HTTPS, for development purposes.
@Everettss @JounQin
I have added same in webpack.client.config.js file but still getting error like
Messaging: We are unable to register the default service worker. Failed to register a ServiceWorker: The script has an unsupported MIME type (‘text/html’). (messaging/failed-serviceworker-registration).
navigator.serviceWorker.register(‘firebase-messaging-sw.js’) .then((registration) => { console.log(‘registration=>’,registration); Vue.prototype.$messaging.useServiceWorker(registration) }).catch(err => { console.log(“here…”) console.log(err) })
Will you please guide me?