【发布时间】:2022-02-07 03:38:40
【问题描述】:
我想从 React 向 Node.js 发出一个 Post 请求,但在 Payload 的开发者工具中,它向我显示了密钥,如果它向我显示我还没有解决任何问题,有什么办法吗?安全地做到这一点?并且在开发者工具中不显示 SECRET KEY?
我的反应发布请求代码
.post("http://.../api/test", {
secret: process.env.REACT_APP_SECRET_KEY,
battleData: battleData,
accountCurent: accountCurent,
})
.then(function (response) {}
....
还有我的 Node.js 代码
app.post("/api/test", (req, res) => {
if(req.body.secret === process.env.REACT_APP_SECRET_KEY){}
...// I only want when Secret Key is identical by Node to the frontEnd and run my code in Node.js
【问题讨论】:
-
如果你在客户端发布它,它在开发者工具中并没有错。