Ionic & Capacitor & PWA : failed to register service worker

Hello, I have an Ionic 5 app, which uses capacitor.
I added a service worker (with ng add @angular/pwa).

If I deploy the build of the application (ionic build --prod --release) on a server, it works. The application is accessible on a browser (https://mysitepwa.com) and updates itself.

After I packaged the application on android (npx cap add android & npx cap open android). The apk opens fine and the application works, except the service worker:

main-es2015.xxx.js:1 Service worker registration failed with: TypeError: Failed to register a ServiceWorker for scope ('http://localhost/') with script ('http://localhost/ngsw-worker.js'): An unknown error occurred when fetching the script.

This is probably normal, because at no time did I enter the url of the website (https://mysitepwa.com), so that the service worker knows where to look for updates.
Or / how do I do this in the app?

"@angular/core": "^10.0.14",
"@ionic/angular": "^5.3.2",
"@ionic-native/core": "^5.26.0",
"@capacitor/android": "^2.4.0",
"@angular/core": "^10.0.14",
"@angular/pwa": "^0.12.4",
"@angular/service-worker": "^10.0.14",
ngsw-config.json :
{
  "$schema": "./node_modules/@angular/service-worker/config/schema.json",
  "index": "/index.html",
  "assetGroups": [
    {
      "name": "app",
      "installMode": "prefetch",
      "resources": {
        "files": [
          "/favicon.ico",
          "/index.html",
          "/manifest.json",
          "/*.css",
          "/*.js"
        ]
      }
    }, {
      "name": "assets",
      "installMode": "lazy",
      "updateMode": "prefetch",
      "resources": {
        "files": [
          "/assets/**",
          "/*.(eot|svg|cur|jpg|png|webp|gif|otf|ttf|woff|woff2|ani)"
        ]
      }
    }
  ]
}

src/manifest.json :
{
  "name": "xxx",
  "short_name": "xxx",
  "theme_color": "#1976d2",
  "background_color": "#fafafa",
  "display": "standalone",
  "scope": "/",
  "start_url": "/",
  "icons": [
    {
      "src": "assets/icons/icon-72x72.png",
      "sizes": "72x72",
      "type": "image/png"
    },
    {
      "src": "assets/icons/icon-96x96.png",
      "sizes": "96x96",
      "type": "image/png"
    },
    {
      "src": "assets/icons/icon-128x128.png",
      "sizes": "128x128",
      "type": "image/png"
    },
    {
      "src": "assets/icons/icon-144x144.png",
      "sizes": "144x144",
      "type": "image/png"
    },
    {
      "src": "assets/icons/icon-152x152.png",
      "sizes": "152x152",
      "type": "image/png"
    },
    {
      "src": "assets/icons/icon-192x192.png",
      "sizes": "192x192",
      "type": "image/png"
    },
    {
      "src": "assets/icons/icon-384x384.png",
      "sizes": "384x384",
      "type": "image/png"
    },
    {
      "src": "assets/icons/icon-512x512.png",
      "sizes": "512x512",
      "type": "image/png"
    }
  ]
}

Thanks

Same probleme on ios with xcode.