Skip to content

Instantly share code, notes, and snippets.

@elgreatly
Last active December 25, 2018 20:29
Show Gist options
  • Save elgreatly/f471044e8a75cac8e96ee7efb8f727ac to your computer and use it in GitHub Desktop.
Save elgreatly/f471044e8a75cac8e96ee7efb8f727ac to your computer and use it in GitHub Desktop.
add custom bots
var express = require('express');
var path = require('path');
var fs = require('fs');
const rendertron = require('rendertron-middleware');
var app = express();
const bots = [
'baiduspider',
'bingbot',
'embedly',
'facebookexternalhit',
'linkedinbot',
'outbrain',
'pinterest',
'quora link preview',
'rogerbot',
'showyoubot',
'slackbot',
'twitterbot',
'vkShare',
'W3C_Validator',
'whatsapp',
];
app.use(rendertron.makeMiddleware({
proxyUrl: "https://render.example.com/render",
userAgentPattern: new RegExp(bots.join('|'), 'i')
}));
app.use(express.static(path.join(__dirname, 'dist')));
app.use('*', express.static(path.join(__dirname, 'dist')));
module.exports = app;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment