我正在将应用程序从使用设计转移到设计令牌身份验证。我已经添加了 gem,设置了所有东西等。我的问题在于,当我从 React(使用 axios)向后端发出请求时,它会返回用户(应该如此),但不会返回访问权限-token 标头。所有,我得到的是:
缓存控制:“最大年龄=0,私有,必须重新验证”内容类型:“应用程序/json;字符集=utf-8”
我确实从后端获取了用户对象,所以我知道这是一个有效的登录。我还看到令牌被添加到数据库中:
更新用户 SET 令牌 = '
这是我通过 axios 打来的电话:
export const userLogin = (options) => ((dispatch) => {
return axios.post(`${process.env.DOMAIN}/auth/sign_in`, {email:
options.username, password: options.password})
.then((response) => {
console.log("response is: ", response);
dispatch(setUser(response))
dispatch(loginError('', false))
})
.catch((response) => {
dispatch(loginError('Username or Password is incorrect, please try again',
true))
})
})
我已经对此进行了大量研究,并尝试恢复到旧版本的 active_model_serializers ,但这并没有帮助。上面的 console.log 显示了很多信息: config data headers request status statusText
响应是 200 OK。