Chrome extension: discard "date" header in ajax request

I have javascript code for api (ajax) and I need to send the "date" header to the api-server (the required header), but chrome tells me "refused to set the unsafe header" "Date" and I get the response from the api server as "missing http date header".

I am using jquery.

code example:

var d = new Date(); var headers = {}; headers["Date"] = d.toUTCString(); jQuery.ajax({ url: '<some HTTPS url>' type: "get", crossDomain: true, headers: headers, .... }) 

the same code works fine in firefox. Does anyone have any ideas how to fix this?

+7
source share
3 answers

Yes, Chrome should refuse your request because the standard says:

Complete these steps if the title matches one of the following titles: [...]

  • date

Link: http://www.w3.org/TR/XMLHttpRequest/#the-setrequestheader-method

+5
source

You can not. Since you are sending an XHR request, it MUST be interrupted according to the standard when setting the entire list of prohibited headers:

http://www.w3.org/TR/XMLHttpRequest2/#the-setrequestheader-method

You will need a proxy server through your source URL or other work.

+2
source

Its lame, because if you use Firefox and RestClient, you can do it. But you cannot if you use Chrome and the "Advanced Rest Client"

0
source

All Articles