I am not able to add Date in the header, every time I add the date I get the error. Refused to set unsafe header "Date"
This is My code;
$http({
method: 'POST',
url: 'https:......',
data: message,
headers: {'Content-Type': 'application/x-www-form-urlencoded',
'XReference':reference,
'Authorization':auth,
'Date':unixtimestamp
}
})
I am not able to add Date in the header, every time I add the date I get the error. Refused to set unsafe header "Date"
This is My code;
$http({
method: 'POST',
url: 'https:......',
data: message,
headers: {'Content-Type': 'application/x-www-form-urlencoded',
'XReference':reference,
'Authorization':auth,
'Date':unixtimestamp
}
})
Share
Improve this question
edited Mar 16, 2016 at 14:23
Hamza Zafeer
2,44613 gold badges35 silver badges47 bronze badges
asked Mar 16, 2016 at 13:38
mulikevsmulikevs
1911 gold badge4 silver badges18 bronze badges
1
-
Since XmlHttpRequest doesn't allow the
Date
header to be set, could you use a custom header of a different name for your purposes? – adam0101 Commented Mar 16, 2016 at 14:26
3 Answers
Reset to default 3Beneath $http
it uses XmlHttpRequest and XmlHttpRequest
isn't allowed to set the Date
header as per the standard.
Step 5 states:
Terminate these steps if header is a case-insensitive match for one of the following headers...
and Date
is included in that list.
It seems like some browsers allow it and others do not.
Try changing "Date" to "Request-Date"
Browsers don't allow you to set the date header in AJAX requests. According to the specification:
Terminate these steps if header is a case-insensitive match for one of the following headers:
- ...
- Date
- ...