在请求头中隐藏授权令牌 || ReactJS

时间:2021-04-09 19:13:51

标签: reactjs http axios request-headers

我在我的 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()

enter image description here

0 个答案:

没有答案