File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed
Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change 3636 "vite" : " ^5.0.0" ,
3737 "@vitejs/plugin-react" : " ^4.2.1" ,
3838 "express" : " ^4.21.2" ,
39+ "express-rate-limit" : " ^7.4.1" ,
3940 "js-yaml" : " ^4.1.0" ,
4041 "@object-ui/react" : " workspace:*" ,
4142 "@object-ui/components" : " workspace:*"
Original file line number Diff line number Diff line change 11import express from 'express' ;
2+ import rateLimit from 'express-rate-limit' ;
23import { existsSync } from 'fs' ;
34import { join , resolve } from 'path' ;
45import chalk from 'chalk' ;
@@ -37,6 +38,18 @@ export async function start(options: StartOptions) {
3738 const port = parseInt ( options . port ) ;
3839 const host = options . host ;
3940
41+ // Configure rate limiting to prevent abuse
42+ const limiter = rateLimit ( {
43+ windowMs : 15 * 60 * 1000 , // 15 minutes
44+ max : 1000 , // Limit each IP to 1000 requests per windowMs
45+ message : 'Too many requests from this IP, please try again later.' ,
46+ standardHeaders : true , // Return rate limit info in the `RateLimit-*` headers
47+ legacyHeaders : false , // Disable the `X-RateLimit-*` headers
48+ } ) ;
49+
50+ // Apply rate limiting to all routes
51+ app . use ( limiter ) ;
52+
4053 // Serve static files from dist directory
4154 app . use ( express . static ( distPath ) ) ;
4255
You can’t perform that action at this time.
0 commit comments