mirror of
https://github.com/wukko/cobalt.git
synced 2025-05-23 18:16:14 +02:00
api/core: return 429 http status for rate-limit (#1066)
Co-authored-by: jj <log@riseup.net>
This commit is contained in:
parent
ad23b70e9d
commit
fa267ae54b
@ -61,13 +61,13 @@ export const runAPI = async (express, app, __dirname, isPrimary = true) => {
|
||||
})
|
||||
|
||||
const handleRateExceeded = (_, res) => {
|
||||
const { status, body } = createResponse("error", {
|
||||
const { body } = createResponse("error", {
|
||||
code: "error.api.rate_exceeded",
|
||||
context: {
|
||||
limit: env.rateLimitWindow
|
||||
}
|
||||
});
|
||||
return res.status(status).json(body);
|
||||
return res.status(429).json(body);
|
||||
};
|
||||
|
||||
const keyGenerator = (req) => hashHmac(getIP(req), 'rate').toString('base64url');
|
||||
|
Loading…
x
Reference in New Issue
Block a user