Cordova: Failed to register a ServiceWorker: The URL protocol of the current origin ('file://') is not supported

I get the error when I run my app on a iOS/Android device with cordova.

What is happening?

Service workers can’t run in Cordova app. They require https server

This is strange. In my build/webpack.config.js I have:

plugins : [
    ...(!isCordova ? [
      new WorkboxPlugin.InjectManifest({
        swSrc: resolvePath('src/service-worker.js'),
    ] : []),

And when I run


I get an apk that requests for service-worker.js

Check your app init, there shouldn’t be service worker included as well

You are right. I have added it manually. So I have solved by removing

          serviceWorker: {
            path: '/service-worker.js',

from my app.vue config.

Thank you for your help.

PS: actually, I consider this consulting…