fix(app/web): accomodate express rate limit breaking change

This commit is contained in:
Simon Lecoq
2023-09-14 05:49:43 +02:00
parent 842cd274f6
commit 183ade98e3

View File

@@ -81,9 +81,12 @@ export default async function({sandbox = false} = {}) {
//Rate limiter middleware
if (ratelimiter) {
app.set("trust proxy", 1)
const disabled = (ratelimiter.max === 0)
if (disabled)
delete ratelimiter.max
middlewares.push(ratelimit({
skip(req, _res) {
return !!cache.get(req.params.login)
return (disabled) || (!!cache.get(req.params.login))
},
message: "Too many requests: retry later",
headers: true,