diff --git a/cli/src/index.ts b/cli/src/index.ts index 1877d143b..173ebb08e 100644 --- a/cli/src/index.ts +++ b/cli/src/index.ts @@ -240,13 +240,14 @@ export function runProgram(config: Config): void { .option('--host ', 'Host used for live reload') .option('--port ', 'Port used for live reload') .option('--configuration ', 'Configuration name of the iOS Scheme') + .option('--https', 'Enable HTTPS for live reload server') .action( wrapAction( telemetryAction( config, async ( platform, - { scheme, flavor, list, json, target, sync, forwardPorts, liveReload, host, port, configuration }, + { scheme, flavor, list, json, target, sync, forwardPorts, liveReload, host, port, configuration, https }, ) => { const { runCommand } = await import('./tasks/run'); await runCommand(config, platform, { @@ -261,6 +262,7 @@ export function runProgram(config: Config): void { host, port, configuration, + https, }); }, ), diff --git a/cli/src/tasks/run.ts b/cli/src/tasks/run.ts index 7217d6123..7ea8916e5 100644 --- a/cli/src/tasks/run.ts +++ b/cli/src/tasks/run.ts @@ -32,6 +32,7 @@ export interface RunCommandOptions { host?: string; port?: string; configuration?: string; + https?: boolean; } export async function runCommand( @@ -90,7 +91,7 @@ export async function runCommand( } const cordovaPlugins = await getCordovaPlugins(config, platformName); if (options.liveReload) { - await CapLiveReloadHelper.editCapConfigForLiveReload(config, platformName, options); + await CapLiveReloadHelper.editCapConfigForLiveReload(config, platformName, options, false, options.https); if (platformName === config.android.name) { await await writeCordovaAndroidManifest(cordovaPlugins, config, platformName, true); } @@ -106,7 +107,7 @@ export async function runCommand( }) .then(() => process.exit()); logger.info( - `App running with live reload listing for: http://${options.host}:${options.port}. Press Ctrl+C to quit.`, + `App running with live reload listing for: ${options.https ? 'https' : 'http'}://${options.host}:${options.port}. Press Ctrl+C to quit.`, ); await sleepForever(); } diff --git a/cli/src/util/livereload.ts b/cli/src/util/livereload.ts index c3b15ee9f..ee9176066 100644 --- a/cli/src/util/livereload.ts +++ b/cli/src/util/livereload.ts @@ -146,6 +146,7 @@ class CapLiveReload { platformName: string, options: RunCommandOptions, rootConfigChange = false, + useHttps = false, ): Promise { const platformAbsPath = platformName == config.ios.name @@ -161,7 +162,7 @@ class CapLiveReload { const configJson = readJSONSync(capConfigPath); this.configJsonToRevertTo.json = JSON.stringify(configJson, null, 2); this.configJsonToRevertTo.platformPath = capConfigPath; - const url = `http://${options.host}:${options.port}`; + const url = `${useHttps ? 'https' : 'http'}://${options.host}:${options.port}`; configJson.server = { url, };