Capacitor Version
@capacitor/cli: 8.0.0
@capacitor/core: 8.0.0
@capacitor/android: 8.0.0
@capacitor/ios: 8.0.0
Bug also present on main branch as of June 2025.
Other API Details
- Node: 24.13.0
- macOS 15
- Android Studio Meerkat 2024.3
- Vite 6.2
- Using
capacitor.config.ts (TypeScript config)
Platforms Affected
Current Behavior
When running npx cap run android --live-reload --external, the editCapConfigForLiveReload function in cli/src/util/livereload.ts destructively replaces the entire server object in the native capacitor.config.json with just { url }.
This strips all other server fields, including:
androidScheme (needed when set to http instead of the default https)
cleartext (needed for HTTP connections on Android)
allowNavigation (needed for CORS/navigation rules)
Root cause in source code:
In cli/src/util/livereload.ts, editCapConfigForLiveReload does:
configJson.server = { url };
Similarly, editExtConfigForLiveReload does:
extConfigJson.server = { url };
Both assignments replace the entire server object rather than merging the url into the existing config.
Example:
Before live reload, native capacitor.config.json contains:
{
"server": {
"androidScheme": "http",
"cleartext": true,
"allowNavigation": ["*.meinestadt.de"]
}
}
After editCapConfigForLiveReload, it becomes:
{
"server": {
"url": "http://localhost:8080"
}
}
The androidScheme, cleartext, and allowNavigation fields are lost.
Expected Behavior
editCapConfigForLiveReload and editExtConfigForLiveReload should merge the url into the existing server object instead of replacing it:
// Instead of:
configJson.server = { url };
// Should be:
configJson.server = { ...configJson.server, url };
And similarly:
// Instead of:
extConfigJson.server = { url };
// Should be:
extConfigJson.server = { ...extConfigJson.server, url };
This preserves all existing server fields (androidScheme, cleartext, allowNavigation, etc.) while adding/overriding the url for live reload.
Project Reproduction
N/A — the bug is in the CLI internals (cli/src/util/livereload.ts), not in app code. It can be verified by reading the two assignment lines in editCapConfigForLiveReload and editExtConfigForLiveReload.
Additional Information
This bug has been reported before but was never properly fixed:
The root cause remains: editCapConfigForLiveReload and editExtConfigForLiveReload use assignment (=) instead of spread ({ ...existing, url }) when setting server. The fix is a one-line change in two places — happy to submit a PR.
Capacitor Version
Bug also present on
mainbranch as of June 2025.Other API Details
capacitor.config.ts(TypeScript config)Platforms Affected
Current Behavior
When running
npx cap run android --live-reload --external, theeditCapConfigForLiveReloadfunction incli/src/util/livereload.tsdestructively replaces the entireserverobject in the nativecapacitor.config.jsonwith just{ url }.This strips all other
serverfields, including:androidScheme(needed when set tohttpinstead of the defaulthttps)cleartext(needed for HTTP connections on Android)allowNavigation(needed for CORS/navigation rules)Root cause in source code:
In
cli/src/util/livereload.ts,editCapConfigForLiveReloaddoes:Similarly,
editExtConfigForLiveReloaddoes:Both assignments replace the entire
serverobject rather than merging theurlinto the existing config.Example:
Before live reload, native
capacitor.config.jsoncontains:{ "server": { "androidScheme": "http", "cleartext": true, "allowNavigation": ["*.meinestadt.de"] } }After
editCapConfigForLiveReload, it becomes:{ "server": { "url": "http://localhost:8080" } }The
androidScheme,cleartext, andallowNavigationfields are lost.Expected Behavior
editCapConfigForLiveReloadandeditExtConfigForLiveReloadshould merge theurlinto the existingserverobject instead of replacing it:And similarly:
This preserves all existing
serverfields (androidScheme,cleartext,allowNavigation, etc.) while adding/overriding theurlfor live reload.Project Reproduction
N/A — the bug is in the CLI internals (
cli/src/util/livereload.ts), not in app code. It can be verified by reading the two assignment lines ineditCapConfigForLiveReloadandeditExtConfigForLiveReload.Additional Information
This bug has been reported before but was never properly fixed:
--live-reload#7528 — PR by @ZeroDX255 (Jul 2024): "fix(livereload): Don't overwrite the whole config.server section in editCapConfigForLiveReload function" — proposed exactly the spread-operator fix, but was closed without merge.cleartext: trueto the replacement object, but still overwrites all other fields (androidScheme,allowNavigation, etc.).The root cause remains:
editCapConfigForLiveReloadandeditExtConfigForLiveReloaduse assignment (=) instead of spread ({ ...existing, url }) when settingserver. The fix is a one-line change in two places — happy to submit a PR.