Express middleware to block browsers requests that do not satisfies the conditions
npm install express-browser-block
import express from 'express';
import { blockRequestIfBrowserIsNot } from 'express-browser-block';
const app = express();
app.use(blockRequestIfBrowserIsNot());
// see API definitions to overwirite default values
app.get('/hello', (req, res) => {
res.send('world');
})
app.listen(3000);
The blockRequestIfBrowserIsNot
functions accepts two parameters: conditions
and html
.
The conditions
parameter follows the definition of the Browser dependency.
The html
is what is going to be send to your user when it doesn't satisfies the conditions
parameter.