ionic-team / capacitor

Build cross-platform Native Progressive Web Apps for iOS, Android, and the Web ⚡️
https://capacitorjs.com
MIT License
12.22k stars 1.01k forks source link

[Bug]: scheme is not respected on capacitor run with live-reload #7669

Open matheo opened 1 month ago

matheo commented 1 month ago

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/android: 6.1.2 @capacitor/core: 6.1.2 @capacitor/cli: 6.1.2 @capacitor/ios: 6.1.2

Other API Details

npm 10.5.0
node v18.20.2

Platforms Affected

Current Behavior

It was reported here that live-reload has a hardcoded scheme and it still seems to be the case on main: https://github.com/ionic-team/capacitor/blob/main/cli/src/util/livereload.ts#L172

Why does the API of this command exposes --scheme if we cannot connect to a localhost served with --ssl? https://capacitorjs.com/docs/cli/commands/run

Expected Behavior

To be able to run ng serve --ssl and connect to it via --live-reload --scheme=https.

Project Reproduction

https://github.com/matheo/capacitor-live-reload-bug

Additional Information

No response

TiBz0u commented 1 month ago

@matheo The exposed scheme in the "run" command correspond to the iOS schemes. It's not linked to the https protocol.

Are you sure you cannot use attribute --port=443 for HTTPS ?

 --live-reload --port 443
jcesarmobile commented 1 month ago

What TiBz0u commented is correct, --scheme is the iOS project scheme, not the live reload url scheme.

The provided app doesn't run using https, so it's not valid to reproduce. Can you provide one that runs the live reload server on https?

matheo commented 1 month ago

@TiBz0u @jcesarmobile so it's impossible to modify the --live-reload-url as it was before, and the capacitor.config will always be updated with an http:// url unable to consume a secure API locally?

I tried to serve --port 443 but that port is already in use, you get a Error: listen EACCES: permission denied 0.0.0.0:443. My point is: live-reload patches the server.url config and it needs to be https for the App to query secure development APIs.

jcesarmobile commented 1 month ago

Capacitor has never supported --live-reload-url, not sure what you are talking about.

You can always edit the capacitor config file manually and edit the sever.url to point to a https url, but don't use the --live-reload option as it will replace whatever you have in the config file

matheo commented 1 month ago

@jcesarmobile oh I see only Ionic has supported a custom url for live-reload and Capacitor has never done that, my fault

TiBz0u commented 1 month ago

@matheo, wondering if it --host <host> does respond to your use case if you want to use only the cli command? @jcesarmobile can you confirm? Thanks