错误的 Content-Type 被替换为获取 http 请求

Wrong Content-Type being substituted for fetch http request

我在客户端有这个代码:

return fetch('http://localhost:8080/api/authenticate', {
    method: 'POST',
    mode: 'no-cors',
    headers: {
        'Content-Type': 'application/json',
    },
    body: JSON.stringify({
        username: 'admin',
        password: 'admin',
    }),
});

当我出于某种原因发送此请求时,Content-Type 被替换为 text/plain;charset=UTF-8。这使我的服务器端请求失败,因为它只接受 application/json 请求。我在这里做错了什么? 我正在使用 Chrome 51,这是我的要求:

编辑: 当我删除 JSON.strigify() Content-Type 和 Request payload 时也被省略了。 这是一个例子:

您已设置 mode: 'no-cors',,因此无法将 'Content-Type' 设置为 'application/json'。它不是 safe values for Content-Type.

之一