首页 > 解决方案 > React axios 响应 -> 授权值未出现在标题中

问题描述

这是我的 API 代码。响应标头中没有授权,但如果您查看“网络”窗口中的标头,它存在。如果您能帮助我找出问题所在以及如何解决,我将不胜感激。

const onLogin = async (event) => {
    event.preventDefault();
    var encrypt = new JSEncrypt();
    encrypt.setPublicKey(REACT_APP_ENC_PUB_KEY);
    let encryptedPassword = encrypt.encrypt(password);
    try {
        let res = await axios.post(
            `http://xx.xx/api/v1/users/login`,
            {
                id: email,
                password: encryptedPassword,
            },
            {
                headers: {
                    Accept: 'application/json',
                    'Content-type': 'Application/json',
                    withCredentials : true
                },
            },
        )}; 
    catch (err) {
        console.log(err);
        let errmsg = err.response.data.message;
        setErrMsg(errmsg);
    }
};

控制台 axios 响应头 网络 axios 响应头

标签: reactjsaxios

解决方案


推荐阅读