question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use service worker on localhost

See original GitHub issue

Current 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:open
  • Created 6 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

0reactions
rahul7pcommented, Dec 6, 2018

@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?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found