I can’t test my Ionic app: Cors error

Asked

Viewed 454 times

0

I’m having a lot of problems testing my Ionic app. As it has Httpclient requests, I am having problems with Cors. I thought about generating the production build and testing on mobile, so I tested:

cordova build android --prod

The app is generated, I copy to my mobile and perform the installation, but when I run it returns:

err_conecttion_refused: localhost:8080

I also tried: Cordova build android --Prod --release But in this case I can’t install the app. How do you test applications that have http requests?

1 answer

1


The problem is the new version of Cordova-plugin-Ionic-webview 2.0 that breaks compatibility with Android 4.4.

The solution is to switch to version 1.2.1:

cordova plugin rm cordova-plugin-ionic-webview
cordova plugin add [email protected]
ionic cordova platforms remove android
rm -rf plugins
ionic cordova build android

I hope I helped. Good luck! ;)

  • but after doing these steps I should run with --Prod --release or just --Prod?

  • can rotate the cordova build android --prod instead of the last step. Custom my use Ionic Cordova build android ^^

  • I did so but now the application starts with a white screen and does not come out of it :

  • Connect the phone to the pc, runs ionic cordova run android -lc. No Chrome accesses chrome://inspect, you will see the device on Remote Target inspect and see on the console if an error appears.

  • If I run with Ionic Cordova run android -Lc the application works until I have some http request, but I can not perform requests on account of Cors, so I would like to build the application, but when I build --release does not install and normal build the white screen app

  • you can use the release and see if there are any errors in the terminal: ionic cordova run android -lc --release My ideas are over. Sorry :| Good luck!

  • All right, just one question, is for me to look at the console of that Chrome research?

  • No. It is not active when you use release. The logs will appear in the place where you executed the( terminal command, e.g.), this happens because of the parameter c in charge

Show 3 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.