skip general rate limiter on dev mode
This commit is contained in:
1 parent
754b0af3a3
commit
c0e33eb4fa
2 files changed
+11
-8
No files matched your search
@@ -1,12 +1,14 @@
|
|||||||
import rateLimit from "express-rate-limit";
|
import rateLimit from "express-rate-limit";
|
||||||
|
|
||||||
export const generalApiLimiter = rateLimit({
|
export const generalApiLimiter = (devMode: boolean) =>
|
||||||
windowMs: 60 * 1000,
|
rateLimit({
|
||||||
limit: 600,
|
windowMs: 60 * 1000,
|
||||||
standardHeaders: true,
|
limit: 600,
|
||||||
legacyHeaders: false,
|
standardHeaders: true,
|
||||||
ipv6Subnet: 64,
|
legacyHeaders: false,
|
||||||
});
|
ipv6Subnet: 64,
|
||||||
|
skip: () => devMode,
|
||||||
|
});
|
||||||
|
|
||||||
export const authApiLimiter = rateLimit({
|
export const authApiLimiter = rateLimit({
|
||||||
windowMs: 60 * 1000,
|
windowMs: 60 * 1000,
|
||||||
|
|||||||
+2
-1
@@ -38,7 +38,8 @@ export const createApp = ({
|
|||||||
};
|
};
|
||||||
const publicStatusPageCorsOrigin = createStatusPageCorsOrigin(allowedOrigin, services.statusPagesRepository);
|
const publicStatusPageCorsOrigin = createStatusPageCorsOrigin(allowedOrigin, services.statusPagesRepository);
|
||||||
|
|
||||||
app.use(generalApiLimiter);
|
const devMode = envSettings.nodeEnv === "development";
|
||||||
|
app.use(generalApiLimiter(devMode));
|
||||||
|
|
||||||
app.use((req, res, next) => {
|
app.use((req, res, next) => {
|
||||||
const corsOptions = isPublicStatusPageApiPath(req.method, req.path)
|
const corsOptions = isPublicStatusPageApiPath(req.method, req.path)
|
||||||
|
|||||||
Reference in new issue
Block a user