我在我的 React 项目中使用 axios 从使用 令牌 进行身份验证的 API 获取数据。现在,我可以获取数据,但是 when I inspect, the token is clearly visible in the Request Headers which is risky.
请建议是否有办法抽象或隐藏请求标头中的令牌以使其更安全。
在代码段下方。
const makeRequest = async () => {
const response = await axios.get(BACKEND_API_URL, { headers: { 'Authorization': 'Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b' } });
if (response.status === 200) {
// do something...
}
}
makeRequest()