Organizational Research By

Surprising Reserch Topic

WinJS - XHR - Is it impossible to set the referer?


I'm working on a WinJS app for a company that uses Referer is their API.

Unfortunately I can't find a way to do this, not even for Cookies!

Here is a code example:

Q.when(WinJS.xhr({
  url: "http://localhost:8888/api/auth/",
  type: "GET",
  headers: {
    "If-Modified-Since": "Mon, 27 Mar 1972 00:00:00 GMT",
    "Referer": "http://localhost:8888/api/"
  }
}));

WinRT seems to use the same behavior IE and other browsers do. Where Referer and Cookie headers are removed from the request.

Any workarounds?

asked Sep 13, 2013 in Microsoft Window 8 by rajesh
edited Sep 12, 2013
0 votes
92 views



Related Hot Questions

1 Answer

0 votes
What about using AtomPubClient as a workaround? Try this: function doRequest3() { var reader; var client = Windows.Web.AtomPub.AtomPubClient(); var uri = new Windows.Foundation.Uri("http://example.com"); client.setRequestHeader("Referer", "http://localhost:8888/api/"); client.retrieveMediaResourceAsync(uri).then(function(stream) { reader = Windows.Storage.Streams.DataReader(stream); return reader.loadAsync(999999); }).done(function (bytesRead) { var contentString = reader.readString(bytesRead); document.getElementById("content").innerText += "Content: " + contentString; }, function (error) { console.log(error); }); }
answered Sep 13, 2013 by rajesh
edited Sep 12, 2013

...