我正在尝试通过对节点api的响应发出axios.post请求。 在我的PC或Mac上,它运行良好,但是在我的iPhone Chrome或Safari中,效果不佳。
代码:
const transport = axios.create({
origin: "http://localhost:3003",
headers: {
'Access-Control-Allow-Origin': '*',
'Content-Type': 'application/json',
},
withCredentials: true,
})
;
transport.post('http://localhost:3001/user/signin', user)
.then(res => {
if(res.status === 200) {
Cookies.set('user', res.data.token, { expires: 7 });
const user = {
fullName: res.data.user.full_name,
email: res.data.user.email,
token: res.data.token
};
props.signIn(user);
history.push('/');
}
})
.catch(err => {
props.clearPropsFromUser();
});
有人可以帮助我吗?谢谢