Replies: 20 comments 12 replies
-
Some people is using the url to point to real websites, so we can't disable it for production as it will break some use cases. Note that this will require Ionic CLI changes as it's Ionic CLI the one that sets the server url, so probably better report it there. https://github.com/ionic-team/ionic-cli/issues |
Beta Was this translation helpful? Give feedback.
-
good point, but yes, it should set a |
Beta Was this translation helpful? Give feedback.
-
my solution is to generate // generate_capacitor_config.js
const ip = require('ip')
const fs = require('fs')
const path = require('path')
const capacitorConfig = {
// ...
server: {},
}
const isHotspotting = (
// Samsung A5 + Macbook
ip.address() === '192.168.43.101' &&
process.env.NODE_ENV !== 'production'
)
if (isHotspotting) {
// support HMR on device
capacitorConfig.server.url = 'http://192.168.43.101:8013'
}
const configPath = path.resolve(__dirname, 'capacitor.config.json')
fs.writeFileSync(configPath, JSON.stringify(capacitorConfig)) // package.json
{
"scripts": {
"build": "export NODE_ENV=production && npm run config && vue-cli-service build --mode development && cap copy",
"config": "node ./generate_capacitor_config.js",
"dev": "npm run config && vue-cli-service serve"
}
} |
Beta Was this translation helpful? Give feedback.
-
that is an interesting though. the issue I'm describing is that it modifies the capacitor config.json on build if you live reload, leading to accidental checkin to git, which essentially breaks the app if someones computer is not hosting the live reload server. There should be a separate file that is used that is ignored by git with any capacitor project. why not name it |
Beta Was this translation helpful? Give feedback.
-
In vue cli plugin capacitor, I modify the |
Beta Was this translation helpful? Give feedback.
-
Any news? I think it's very confusing and @agrosner solution sounds great.. |
Beta Was this translation helpful? Give feedback.
-
Would it also be possible to only use |
Beta Was this translation helpful? Give feedback.
-
Yes, that's possible, but Apple will probably not approve your app if you do that. |
Beta Was this translation helpful? Give feedback.
-
Any way to get this on a future milestone? |
Beta Was this translation helpful? Give feedback.
-
Just don't check in your |
Beta Was this translation helpful? Give feedback.
-
@agrosner Have you gotten a chance to use the new Ionic CLI which clears out the server URL and runs a copy when cancelled? It should achieve the behavior you're looking for. |
Beta Was this translation helpful? Give feedback.
-
I advocate that the development livereload url is handled in a different file or I can be permanently active in the development environment. |
Beta Was this translation helpful? Give feedback.
-
Perhaps Capacitor 3.X will partially solve this issue, but the native |
Beta Was this translation helpful? Give feedback.
-
I customized the @diachedelic script to automatically update |
Beta Was this translation helpful? Give feedback.
-
Hi all, presented workarounds sound good, but I've never been able to get Ionic build to respect custom build scripts. Is there any way I can hook any of these solutions into ionic build/appflow ? I'm sorry if I'm missing sth, I'm no expert in the matter |
Beta Was this translation helpful? Give feedback.
-
I'm a bit confused, it's not really explained in any guide what the |
Beta Was this translation helpful? Give feedback.
-
Any solution? |
Beta Was this translation helpful? Give feedback.
-
Just for anyone who comes across this - I have an app in both the iOS and Android play stores that use server url in production. They got past the verification just fine. |
Beta Was this translation helpful? Give feedback.
-
I'm curious is there a way to change the server URL value from within the app code? Perhaps I want a way for users to toggle between different experiences of the app, or I want to target different servers based on some feature flag or some variable only known at runtime. |
Beta Was this translation helpful? Give feedback.
-
You may specify the This allows you to read When you run the app, you would then run e.g. Additionally, if you're using Vite, it's important to note that NODE_ENV (process.env.NODE_ENV) and modes are two different concepts. |
Beta Was this translation helpful? Give feedback.
-
Currently, when running the app with livereload enabled via:
will insert into our
capacitor.config.json
a server url:This is problematic because if this is ever accidently committed to the repo, on launch from a production build from a CI server, it will still look for that URL, and users would be presented with a blank app screen that never loads.
This is a request to provide a way to turn off url searching, or provide a better way to set up live reloading without need for it to modify this file in the first place, possibly through the tooling in a different way.
Beta Was this translation helpful? Give feedback.
All reactions