Jon*_*Jon 5 node.js express reactjs express-rate-limit
我有带有 Express 和 React 捆绑包的 VPS。问题是,当我从前端访问 API 时,我得到相同的 IP 地址(localhost),因此我无法正确使用express-rate-limit。
我有一个快递服务器:
const apiLimiter = rateLimit({
windowMs: 1 * 60 * 1000,
max: 30
});
app.use("/api/", apiLimiter);
app.use(express.static('client/build'));
app.get('*', (req, res) => {
res.sendFile(path.resolve(__dirname, 'client', 'build', 'index.html'));
});
Run Code Online (Sandbox Code Playgroud)
和前端的 package.json 中的代理配置:
"proxy": "http://localhost:3000/"
Run Code Online (Sandbox Code Playgroud)
如何修复它并正确使用express-rate-limit?