Last active
December 25, 2018 20:29
-
-
Save elgreatly/f471044e8a75cac8e96ee7efb8f727ac to your computer and use it in GitHub Desktop.
add custom bots
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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