Capacitor production builds retaining development server.url configuration
0 reputation · 18 Apr 2021, 19:19 UTC
0 reputation · 18 Apr 2021, 19:19 UTC
Capacitor's server.url setting in capacitor.config.json directs the WebView to a local development server for live reload. The documentation marks this as a development-only feature, yet the CLI does not automatically remove or override the value when running capacitor build ios or capacitor build android. If the key remains, the packaged app attempts to load http://localhost:8100 on the device, resulting in a white screen or connection error with no actionable log output.
--prod) strips server.url or server.cleartext during the sync or copy phases.capacitor.config.prod.json) or migrate to capacitor.config.ts with process.env.NODE_ENV checks, which adds a TypeScript compilation step.Establish a reliable, low-maintenance strategy that guarantees server.url and server.cleartext are absent from production native projects without relying on manual steps or custom scripts that diverge across repositories.
server.cleartext flag be validated as disabled in production builds as part of an automated check?A thoughtful contribution can make all the difference. Be the first to share one.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.