在网络请求中未设置引荐来源网址标头 [英] Referrer header is not set in web requests

查看:279
本文介绍了在网络请求中未设置引荐来源网址标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我通过Phonegap加载Web应用程序并发出Web请求(通过AJAX或其他方式)时,REFERRER HTTP标头根本不会设置。这会干扰一些第三方网站的功能。如何发送REFERRER标头?

When I load my web app via Phonegap and make a web request (via AJAX or otherwise), the REFERRER HTTP header is not set at all. This is interfering with the functionality of some third-party websites. How can I make the REFERRER header get sent?

(我使用Phonegap 3.5.0-0.20.10)

(I am using Phonegap 3.5.0-0.20.10)

推荐答案

@JamesWong告诉我们,现在有一个名为的插件cordovaHttp 适用于所有平台。

As told by @JamesWong, now there is a plugin named cordovaHttp available for all platforms.

您可以使用 cordova插件添加该插件add https://github.com/wymsee/ cordova-HTTP.git 命令,然后您可以添加任何http标头如下。

You can add that plugin using cordova plugin add https://github.com/wymsee/cordova-HTTP.git command and then you can add any http header as below.

cordovaHTTP.post("https://google.com/, {
    id: 12,
    message: "test"
}, { Authorization: "OAuth2: token" }, function(response) {
    // prints 200
    console.log(response.status);
    try {
        response.data = JSON.parse(response.data);
        // prints test
        console.log(response.data.message);
    } catch(e) {
        console.error("JSON parsing error");
    }
}, function(response) {
    // prints 403
    console.log(response.status);

    //prints Permission denied 
    console.log(response.error);
});

资料来源: https://github.com/wymsee/cordova-HTTP

这篇关于在网络请求中未设置引荐来源网址标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆