2

i built phonegap app using polymer but while application is started and i debugged it in chrome i seen following error in console.

Uncaught (in promise) DOMException: Failed to register a ServiceWorker: The URL protocol of the current origin ('file://') is not supported.

Anyone know how to use service worker with file:// origin?

Mitul Gedeeya
  • 886
  • 1
  • 10
  • 20

1 Answers1

0

I don't think you can because of security considerations.

Instead you need to run a local web server. Chrome offers one https://chrome.google.com/webstore/detail/web-server-for-chrome/ofhbbkphhbklhfoeikjpcbhemlocgigb I am a fan of node connect https://www.npmjs.com/package/connect

Chris Love
  • 3,740
  • 1
  • 19
  • 16
  • Thank you for Reply !! By further reading i found that service workers can work with HTTP or localhost only. – Mitul Gedeeya Jun 16 '17 at 05:57
  • But would the local web server not lose all of its state (such as anything cached) every time it was started? In addition, you would have to arrange for the `index.html` to be served from the web server as well, and I have no idea how to do something like that in Cordova. The `content` element in `config.xml` gives a file name, which Cordova looks for in its `assets` directory. –  Jun 10 '18 at 06:22