I have VPS with express and react bundle. The problem is that I get the same IP address (localhost) when I access the API from the frontend, therefore I cannot correctly use the express-rate-limit.
I have an express server:
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'));
});
and proxy config in package.json of frontend:
"proxy": "http://localhost:3000/"
How to fix it and use express-rate-limit correctly?
Per https://www.npmjs.com/package/express-rate-limit#usage
app.set('trust proxy', 1)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With