Reactjs 使用Isomarpic fetch在react中忽略fetch POST API的标头
后端服务器:使用SpringOAuth2实现google身份验证 通过以上的细节,我试图找到一个api端点,如下所示Reactjs 使用Isomarpic fetch在react中忽略fetch POST API的标头,reactjs,post,fetch,credentials,isomorphic-fetch-api,Reactjs,Post,Fetch,Credentials,Isomorphic Fetch Api,后端服务器:使用SpringOAuth2实现google身份验证 通过以上的细节,我试图找到一个api端点,如下所示 fetch(`http://localhost:8080/users`, { credentials: 'include', headers: { 'Content-Type':'application/json', Accept: 'application/json' },
fetch(`http://localhost:8080/users`,
{
credentials: 'include',
headers: {
'Content-Type':'application/json',
Accept: 'application/json'
},
method : 'POST',
body : JSON.stringify(user)
})
.then(response => {
return response.status
})
这会给我一个状态代码302,并且头永远不会被设置为请求头的一部分。除此之外,cookies从未设置
我已经浪费了整整两天的时间来理解为什么没有设置标题,并且已经在SO和github上浏览了很多帖子,我们中没有人帮过我
因此,非常感谢您的帮助
谢谢,
Kiran终于能够找到一种方法来使用我的PostAPI了 我在本地运行前端和后端服务器,但在不同的端口上运行。但在这种情况下,chrome或Firefox不支持包含标题 需要在禁用模式下在web安全中运行 ubuntu计算机: google chrome--user data dir=“/var/tmp/chrome”--禁用web安全