ionic app cannot connect cors enabled server with $http

折月煮酒 提交于 2019-11-27 09:05:26

cordova-plugin-whitelist seems to be "mandatory" at present.

install it :

cordova plugin add cordova-plugin-whitelist

configure config.xml

You can keep your current setup with * or change for more restrictive rules

add a html policy on index.html, you shall add a Policy also. To authorise everything, here it is :

 <meta http-equiv="Content-Security-Policy" content="default-src *;
 style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline'
 'unsafe-eval'"

you can just go into config .xml file and edit this line

<access origin="*://*/*" />

and you can call any data with out intruption of CORS in console thank you plz apply this code your ionic app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!