Ionic应用程序不在移动设备上工作。

时间:2022-05-12 19:49:55

I have created an ionic application, where i am accessing the data from a different domain. In order to make it work, have done the following at server side(express):

我创建了一个ionic应用程序,我正在访问来自不同域的数据。为了使其工作,在服务器端完成以下操作(express):

app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "http://localhost:8100");
res.header("Access-Control-Allow-Methods",  "GET,PUT,POST,DELETE,OPTIONS");
res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type, Authorization, Access-Control-Allow-Origin, Access-Control-Allow-Headers');
res.header("Access-Control-Allow-Credentials", "true");
next();
});

As seen, i have set origin to localhost:8100, which is making my application to work and run properly on browser. However, when i create an .apk file and install on my mobile device, its not working i.e. the data is not coming.

如图所示,我已经将源设置为localhost:8100,这使我的应用程序能够正常工作并在浏览器上正常运行。然而,当我创建一个.apk文件并在我的移动设备上安装时,它不工作,即数据不来。

Could someone please help me out with this issue. Is the issue arising because of the origin specified ? If yes, is there any solution for the same.

有人能帮我解决这个问题吗?是否因指定的来源而引起的问题?如果是,是否有相同的解决方案?

1 个解决方案

#1


0  

Do you have a cordova whitelist plugin. If yes , check the access origin settings in config.xml and meta tag for security in index.html. validate your settings from https://github.com/apache/cordova-plugin-whitelist

你有科尔多瓦白名单插件吗?如果是,请检查配置中的访问源设置。在index.html中用于安全的xml和元标记。验证您的设置来自https://github.com/apache/cordova-plugin-whitelist。

#1


0  

Do you have a cordova whitelist plugin. If yes , check the access origin settings in config.xml and meta tag for security in index.html. validate your settings from https://github.com/apache/cordova-plugin-whitelist

你有科尔多瓦白名单插件吗?如果是,请检查配置中的访问源设置。在index.html中用于安全的xml和元标记。验证您的设置来自https://github.com/apache/cordova-plugin-whitelist。