Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Cordova Android应用程序可以';禁止使用403号邮政编码_Cordova_Http Status Code 403 - Fatal编程技术网

Cordova Android应用程序可以';禁止使用403号邮政编码

Cordova Android应用程序可以';禁止使用403号邮政编码,cordova,http-status-code-403,Cordova,Http Status Code 403,我有一个接受post请求的JavaREST服务。我的Cordova打包为Android应用程序,无法发出post请求 我得到一个403禁止的错误。我知道很多人提出了很多建议。所有这些我都试过了,但还是解决不了。任何帮助都会大有帮助 我的Cordova配置文件如下所示 <content src="index.html" /> <plugin name="cordova-plugin-whitelist" spec="1" /> <access orig

我有一个接受post请求的JavaREST服务。我的Cordova打包为Android应用程序,无法发出post请求

我得到一个403禁止的错误。我知道很多人提出了很多建议。所有这些我都试过了,但还是解决不了。任何帮助都会大有帮助

我的Cordova配置文件如下所示

<content src="index.html" />
<plugin name="cordova-plugin-whitelist" spec="1" />    
    <access origin="*" />
<access uri="*" subdomains="true" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
    <allow-intent href="*" />
</platform>
<platform name="ios">
    <allow-intent href="itms:*" />
    <allow-intent href="itms-apps:*" />
</platform>


根据某人的建议,我试着删除。但是仍然不起作用。

您在Ajax中使用cookies吗

var request = new XMLHttpRequest(),
    data = {name:'name'},
    url = 'https://example.com';
request.setRequestHeader("cookieItem1", "cookieContent1");
request.setRequestHeader("cookieItem2", "cookieContent2");
request.open("POST", url);
request.send(JSON.stringify(data));

我尝试了这个方法来解决这个问题。

您在Ajax中使用cookies吗

var request = new XMLHttpRequest(),
    data = {name:'name'},
    url = 'https://example.com';
request.setRequestHeader("cookieItem1", "cookieContent1");
request.setRequestHeader("cookieItem2", "cookieContent2");
request.open("POST", url);
request.send(JSON.stringify(data));

我试图解决这个问题。

以防万一有人遇到这个问题。问题可能是由于CORS问题。通常,来自cordova应用程序的http调用设置了origin=file://头。某些web服务器可能具有安全过滤器以防止安全攻击

最简单的方法是确保正在执行http请求的服务器不会在源文件头具有file://值时阻止它们。看


否则,在发出请求之前,您需要找到将标题更改为其他内容的方法。

以防有人遇到此问题。问题可能是由于CORS问题。通常,来自cordova应用程序的http调用设置了origin=file://头。某些web服务器可能具有安全过滤器以防止安全攻击

最简单的方法是确保正在执行http请求的服务器不会在源文件头具有file://值时阻止它们。看

否则,在发出请求之前,您需要找到一种方法将标题更改为其他内容