Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Hardcoded HTTP protocol for LiveReload prevents using HTTPS #7745

Closed
1 of 3 tasks
MirazMac opened this issue Nov 1, 2024 · 2 comments
Closed
1 of 3 tasks

[Bug]: Hardcoded HTTP protocol for LiveReload prevents using HTTPS #7745

MirazMac opened this issue Nov 1, 2024 · 2 comments
Labels

Comments

@MirazMac
Copy link

MirazMac commented Nov 1, 2024

Capacitor Version

 Capacitor Doctor

Latest Dependencies:

  @capacitor/cli: 6.1.2
  @capacitor/core: 6.1.2
  @capacitor/android: 6.1.2
  @capacitor/ios: 6.1.2

Installed Dependencies:

  @capacitor/ios: not installed
  @capacitor/cli: 6.1.2
  @capacitor/core: 6.1.2
  @capacitor/android: 6.1.2

[success] Android looking great! 👌

Other API Details

npm --version
10.9.0

node --version
v22.11.0

Platforms Affected

  • iOS
  • Android
  • Web

Current Behavior

Despite setting an HTTPS URL in capacitor.config.ts, when ionic capacitor run android --livereload --external is run, the app loads the HTTP version of the URL.

import type { CapacitorConfig } from '@capacitor/cli';

const config: CapacitorConfig = {
  appId: 'io.ionic.starter',
  appName: 'LivSports',
  webDir: 'dist',
  server: {
    androidScheme: "https",
    url: "https://192.168.1.5:8100",
  }
};

export default config;

Upon inspecting the generated android\app\src\main\assets\capacitor.config.json file, it also shows that is it has removed the HTTPS from the URL and is using the HTTP instead.

{
	"appId": "io.ionic.starter",
	"appName": "LivSports",
	"webDir": "dist",
	"server": {
		"androidScheme": "https",
		"url": "http://192.168.1.5:8100"
	}
}

However, once the dev server exits this file changes the URL to https:// again.

It seems http is being hardcoded here:

const url = `http://${options.host}:${options.port}`;

Expected Behavior

Ionic should use the server URL set in the config AS-IS. Stripping the protocol and using http by default defeats the purpose of setting an custom server URL entirely.

Project Reproduction

https://github.com/ionic-team/starters

Additional Information

My dev server is properly configured to use SSL, I generated the certificates and keys and added everything to the trust root and the live-server URL is accessible without any warnings in my phone via Chrome.

@MirazMac MirazMac added the triage label Nov 1, 2024
@jcesarmobile
Copy link
Member

You are using ionic command to run the app, when using ionic command to run the app, the Capacitor livereload code is not used.
You should be able to use https with ionic command by adding --ssl option.

androidScheme is not used for the live reload url, just for the url used for loading local assets.

@jcesarmobile jcesarmobile closed this as not planned Won't fix, can't repro, duplicate, stale Nov 6, 2024
Copy link

ionitron-bot bot commented Dec 6, 2024

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Dec 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants