【发布时间】:2020-12-05 21:12:32
【问题描述】:
我有带有 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'));
});
以及前端的package.json中的代理配置:
"proxy": "http://localhost:3000/"
如何解决并正确使用 express-rate-limit?
【问题讨论】:
标签: node.js reactjs express express-rate-limit