[英]Why can I not see my HTTP headers in Chrome?
I am performing a fetch: 我正在执行提取:
fetch(url, fetchOptions);
fetchOptions
is configured like so: fetchOptions
的配置如下:
var fetchOptions = {
method: options.method,
headers: getHeaders(),
mode: 'no-cors',
cache: 'no-cache',
};
function getHeaders() {
var headers = new Headers(); // Headers is part of the fetch API.
headers.append('User-ID', 'foo');
return headers;
}
Checking fetchOptions at runtime it looks as follows: 在运行时检查fetchOptions如下所示:
fetchOptions.headers.keys().next() // Object {done: false, value: "user-id"}
fetchOptions.headers.values().next() // Object {done: false, value: "foo"}
But user-id is nowhere to be found in the request headers per Chrome dev tools: 但是在每个Chrome开发者工具的请求标头中都找不到用户ID:
GET /whatever?a=long_name&searchTerm=g HTTP/1.1
Host: host:8787
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
accept: application/json
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36
Referer: http://localhost:23900/
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-US,en;q=0.8,fr;q=0.6
Why can I not see my "User-ID" header in Chrome dev tools, and why does the header key appear to have been lowercased? 为什么在Chrome开发工具中看不到我的“ User-ID”标头,为什么标头键似乎是小写的?
Incase someone else has a similar problem there were two possible culprits for this: 如果其他人有类似的问题,可能有两个罪魁祸首:
The following didn't work when run from a Windows shortcut: 从Windows快捷方式运行时,以下内容不起作用:
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" -enable-precise-memory-info -disable-web-security
The following did work when run from a Windows command prompt: 从Windows命令提示符运行时,以下命令可以正常工作:
C:\whatever\48.0.2564.82\application\chrome.exe --disable-web-security --user-data-dir=C:\whatever\tmp\chrome
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.