I'm trying to call vuforia's webservice using react + axios, reading the docs of vuforia and following those steps when I make the call I get an error in chrome's console log which is:
xhr.js:121 Refused to set unsafe header "Date"
But if I understand correctly I have to declare the header "Date" in the request. How can I solve that, here is my code:
class App extends Component {
componentDidMount() {
var md5 = require('md5');
var base64 = require('base-64');
var hmacsha1 = require('hmacsha1');
var contentType = "application/json";
var hexDigest = "d41d8cd98f00b204e9800998ecf8427e";
var accessKey = "xxxxxxxxxxxx";
var secretKey = "xxxxxxxxxxx";
var date = new Date().toUTCString();
var url = `${'https://cors-anywhere.herokuapp.com/'}https://vws.vuforia.com/targets`;
var dateValue = date;
var requestPath = url;
var newLine = '\n';
var toDigest = `GET${newLine}${hexDigest}${newLine}${contentType}${newLine}${dateValue}${newLine}${requestPath}`;
var shaHashed = hmacsha1(secretKey, toDigest);
var signature = base64.encode(shaHashed);
const config = {
headers: {
'Date': `${date}`,
'Authorization': `VWS ${accessKey}:${signature}`
}
}
console.log(toDigest);
axios.get(url, config,{ crossdomain: true })
.then(json => console.log(json))
}
console.log(toDigest):
GET
d41d8cd98f00b204e9800998ecf8427e
application/json
Mon, 29 Oct 2018 12:45:26 GMT
https://cors-anywhere.herokuapp.com/https://vws.vuforia.com/targets