Skip to content

best way to save what you love

api/core: move ratelimiters before authentication handler

dumbmoron57c9836f5634
diff --git a/api/src/core/api.js b/api/src/core/api.js
index c96c1cf1..51ec1697 100644
--- a/api/src/core/api.js
+++ b/api/src/core/api.js
@@ -102,6 +102,9 @@ export const runAPI = (express, app, __dirname) => {
...corsConfig,
}));
+ app.post('/', apiLimiter);
+ app.use('/tunnel', apiLimiterStream);
+
app.post('/', (req, res, next) => {
if (!env.turnstileSecret || !env.jwtSecret) {
return next();
@@ -140,9 +143,6 @@ export const runAPI = (express, app, __dirname) => {
next();
});
- app.post('/', apiLimiter);
- app.use('/tunnel', apiLimiterStream);
-
app.use('/', express.json({ limit: 1024 }));
app.use('/', (err, _, res, next) => {
if (err) {