Просмотр исходного кода

fix(dashboard): Further fix to rate limiting in dev mode

Michael Bromley 4 недель назад
Родитель
Сommit
a335a60b23
1 измененных файлов с 4 добавлено и 3 удалено
  1. 4 3
      packages/dashboard/plugin/dashboard.plugin.ts

+ 4 - 3
packages/dashboard/plugin/dashboard.plugin.ts

@@ -150,6 +150,7 @@ export interface DashboardPluginOptions {
 })
 export class DashboardPlugin implements NestModule {
     private static options: DashboardPluginOptions | undefined;
+    private readonly rateLimitRequests = process.env.NODE_ENV === 'production' ? 500 : 100_000;
 
     constructor(private readonly processContext: ProcessContext) {}
 
@@ -185,7 +186,7 @@ export class DashboardPlugin implements NestModule {
     private createStaticServer(dashboardPath: string) {
         const limiter = rateLimit({
             windowMs: 60 * 1000,
-            limit: process.env.NODE_ENV === 'production' ? 500 : 1_000_000,
+            limit: this.rateLimitRequests,
             standardHeaders: true,
             legacyHeaders: false,
         });
@@ -240,7 +241,7 @@ export class DashboardPlugin implements NestModule {
     private createDefaultPage() {
         const limiter = rateLimit({
             windowMs: 60 * 1000,
-            limit: process.env.NODE_ENV === 'production' ? 500 : 20_000,
+            limit: this.rateLimitRequests,
             standardHeaders: true,
             legacyHeaders: false,
         });
@@ -267,7 +268,7 @@ export class DashboardPlugin implements NestModule {
     private createDynamicHandler(route: string, appDir: string, viteDevServerPort: number) {
         const limiter = rateLimit({
             windowMs: 60 * 1000,
-            limit: process.env.NODE_ENV === 'production' ? 500 : 2000,
+            limit: this.rateLimitRequests,
             standardHeaders: true,
             legacyHeaders: false,
         });