Skip to content

feat(cli)!: merge live-reload options into --url#8468

Open
OS-pedrogustavobilro wants to merge 1 commit into
nextfrom
breaking/merge-livereload-options
Open

feat(cli)!: merge live-reload options into --url#8468
OS-pedrogustavobilro wants to merge 1 commit into
nextfrom
breaking/merge-livereload-options

Conversation

@OS-pedrogustavobilro
Copy link
Copy Markdown
Contributor

⚠️🤖 AI-Assisted development with Claude Code 🤖⚠️

Description

This PR unifies the live reload CLI arguments in cap run--live-reload (or -l) --host --port --https -> into a single --url argument. if we wanted to point to a local network vite server, we had to separate host from the port like so:

npx cap run -l --host 192.168.1.181 --port 5173

Now it's simply copy the url from the command line that vite outputs and paste it into can run command:

npx cap run --url http://192.168.1.181:5173

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

  • Fix
  • Feature
  • Refactor
  • Breaking Change - to go in Capacitor 9. Since the CLI options change it can break existing apps that are using the current live reload parameters.
  • Documentation

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 do npm run dev, to use HTTPS you can use a tool like ngrok ngrok http 5173; in another terminal tab you paste the url from vite / ngrok into the cap run command.

@OS-pedrogustavobilro OS-pedrogustavobilro changed the title feat(cli): merge live-reload options into --url feat(cli)!: merge live-reload options into --url May 11, 2026
Comment thread cli/src/tasks/run.ts
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}//")`);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants