added express-rate-limit middleware to Web UI
parent
98f09259db
commit
9db895d191
|
@ -1,11 +1,20 @@
|
||||||
const compression = require('compression');
|
const compression = require('compression');
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const bodyParser = require('body-parser');
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const app = express();
|
const app = express();
|
||||||
app.use(compression());
|
app.use(compression());
|
||||||
app.disable('x-powered-by');
|
app.disable('x-powered-by');
|
||||||
app.use(express.static(path.join(__dirname, 'build')));
|
app.use(express.static(path.join(__dirname, 'build')));
|
||||||
|
|
||||||
|
// set up rate limiter: maximum of five requests per minute
|
||||||
|
var RateLimit = require('express-rate-limit');
|
||||||
|
var limiter = new RateLimit({
|
||||||
|
windowMs: 1*60*1000, // 1 minute
|
||||||
|
max: 5 // limit each IP to 5 requests per windowMs
|
||||||
|
});
|
||||||
|
// apply rate limiter to all requests
|
||||||
|
app.use(limiter);
|
||||||
|
|
||||||
// need to declare a "catch all" route on your express server
|
// need to declare a "catch all" route on your express server
|
||||||
// that captures all page requests and directs them to the client
|
// that captures all page requests and directs them to the client
|
||||||
// the react-router do the route part
|
// the react-router do the route part
|
||||||
|
|
Loading…
Reference in New Issue