Skip to content

Commit 6f5b364

Browse files
committed
fix(API): ensure rate limiting is applied to API only
1 parent 7c19813 commit 6f5b364

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

server/server.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ if (!process.env.ORG_ID) {
2222
exit(1);
2323
}
2424

25-
const limiter = rateLimit({
25+
const apiLimiter = rateLimit({
2626
windowMs: 10 * 60 * 1000, // 10 minutes
27-
limit: 300, // limit each IP to 300 requests per windowMs
27+
limit: 400, // limit each IP to 400 requests per windowMs
2828
keyGenerator: (req) => {
2929
const forwardFor = req.headers['x-forwarded-for'];
3030
if (forwardFor && typeof forwardFor === 'string') {
@@ -54,7 +54,6 @@ await mongoose
5454
debugDB("Connected to MongoDB Atlas.");
5555

5656
app.set("trust proxy", 1); // Trust first proxy (i.e. ALB)
57-
app.use(limiter);
5857
app.use(cookieParser());
5958
app.use(helmet.hidePoweredBy());
6059
app.use(
@@ -105,7 +104,7 @@ app.use(
105104
);
106105

107106
// Serve API
108-
app.use("/api/v1", api);
107+
app.use("/api/v1", apiLimiter, api);
109108
app.use("/permalink", permalinkRouter);
110109

111110
app.use("/health", (_req, res) =>

0 commit comments

Comments
 (0)