Ionic 5 Http failure response for (unknown url): 0 Unknown Error in ionic capacitor. when calling api on simulator

I have an ionic 5 capacitor application that calls a .NET Core backend API. It works correctly on chrome browser and android device , (emulator and real device) after build.

When I run using this command ionic cap run ios -l --external it’s working fine REST API on IOS simulator.

But If I run this command ionic cap build ios after that run simulator then REST API not working.

Have searched many solutions on google and applied in the application code but have not found any solution. Please help me how can I do this?


Probably 90% of the “error code 0” posts I see here are caused by one of two things:

  • trying to use insecure http endpoints instead of https ones
  • insufficient CORS setup on server