electroncapacitor

Electron change hostname


My Capacitor Electron app starts with hostname hyphen(-)

    capacitor-electron://-/

I want to change the hostname to some string, but can't find any option for this.

    capacitor-electron://abc/

Solution

  • Make sure that you are using at least version 1.2 of the electron-serve package in electron/package.json (not in the main package.json)

    Then, add hostname option to the electronServe call in electron/src/setup.ts:

    // Setup our web app loader, this lets us load apps like react, vue, and angular without changing their build chains.
    this.loadWebApp = electronServe({
      directory: join(app.getAppPath(), 'app'),
      scheme: this.customScheme,
      hostname: 'abc',
    });