I've developed small website done by PreactJS which has some parts of main website (PHP). As we all know, Facebook bot cannot crawl javascript pre-render content while sharing. That's why I want to redirect as letting facebook bot to crawl main website (PHP) while sharing a link of website done by PreactJS in NodeJS/ExpressJS as follow:
if user is sharing like, 'https://www.mywebsite.com/category/trips/10' I want nodejs/express to redirect 'https://main.mywebsite.com/category/trips/10'. Can anyone tell me how can I do like that in expressjs level as follow:
app.use('/*', function(req, res){
if(req.headers['user-agent'] === 'facebookexternalhit/1.1') {
}
});