简体   繁体   中英

Ionic with .net core backend to android app using capacitor

I am new to Ionic and in fact new to building apps altogether.
So far I have built an app successfully. This is what I have done so far:

Following Ionic docs, I built it using Ionic build --prod and saved the build in wwwroot folder inside Api. Publishes using dotnet release. Then uploaded to a hosted server. It's running fine on the web.
Now, I have used the following to convert the project to android app.
1. Ran ionic capacitor add android
2. Ionic cap copy android
3. Ionic cap open android
This opens the android studio and it is built correctly.
When I debug the app in android studio the home page loads fine (it is a static page which doesn't make api call).
What is especially bugging me is that the debug window shows its running on localhost, whereas I have used the url of the hosted server. When I click on any links, they too, again, point to localhost. I have also added
"proxies":

  [ <br/>
    {<br/>
      "path": "/api/",<br/>
      "proxyUrl": "http://apiurl.com"<br/>
    }<br/>
  ] <br/>

in config.json
I am sure I am missing a point. Can some enlightened being point me towards right direction? Thanks!

I got around it eventually. For anyone else facing similar situation, this is what we need to do. In capacitor.config.json file we need to specify 'server' from where we are getting the Api data.

"appName": "Your Site",
"bundledWebRuntime": false,
"npmClient": "npm",
"webDir": "www",
"cordova": {},

//This part mentioned below is important.
"server": {
  "url": "https://yoursite.com",
  "allowNavigation": ["yoursite.com", "*.yoursite.com"]
} 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM