feat(cli)!: merge live-reload options into --url#8468
Open
OS-pedrogustavobilro wants to merge 1 commit into
Open
feat(cli)!: merge live-reload options into --url#8468OS-pedrogustavobilro wants to merge 1 commit into
--url#8468OS-pedrogustavobilro wants to merge 1 commit into
Conversation
Alternative solution to #8376
--url--url
jcesarmobile
requested changes
May 25, 2026
| try { | ||
| const parsed = new URL(options.url); | ||
| if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') { | ||
| fatal(`Invalid --url: must use http:// or https:// (got "${parsed.protocol}//")`); |
Member
There was a problem hiding this comment.
calling fatal inside the try-catch will trigger the catch, so this message is never displayed, if you want to get this message you should put only the const parsed = new URL(options.url); inside the try-catch and then if it wasn't triggered, throw the fatal if the protocol is not valid
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR unifies the live reload CLI arguments in cap run
--live-reload(or-l)--host--port--https-> into a single--urlargument. if we wanted to point to a local network vite server, we had to separate host from the port like so:Now it's simply copy the url from the command line that vite outputs and paste it into can run command:
There was a bit of logic related to getting a local IP in the CLI that now becomes unused, so I removed it.
Change Type
Rationale / Problems Fixed
Alternative solution to a recent PR that removed a default port in live reload, as suggested in #8376 (comment), that some time ago the team internally agreed was better, but never reserved the time to do it.
Tests or Reproductions
You can test this updated functionality in any capacitor app. For convenience I have https://github.com/OS-pedrogustavobilro/capacitor-test-livereload.
There you need to run
npm ci,npm run build+npx cap sync. So start a vite server you donpm run dev, to use HTTPS you can use a tool like ngrokngrok http 5173; in another terminal tab you paste the url from vite / ngrok into the cap run command.