I'm working on a headless solution to give bots SSR, save the renderings on a firebase bucket. I've deployed a working Rendertron heroku app at https://xymba-renderbot.herokuapp.com/render/ .
This app works well enough with direct tests and on Google's mobile-friendly test. Serving local works, too from vue.config.js devServer proxy.
However, when I deploy the app to Vercel including the specified middleware in index.js, doesn't seem like I know how to test or the BOTS aren't config'd right (Heroku has the renderbot separately from the main app at Vercel)
To recap, I'm running Rendertron, need to learn how to send bots to the /render endpoint, and how to pipe the renderings as static files to be saved. Am I missing something or is this not possible from vue-cli?
index.js
const express = require('express');
const serveStatic = require('serve-static')
const path = require('path');
app = express();
const rendertron = require('rendertron-middleware');
const BOTS = rendertron.botUserAgents.concat('googlebot');
const BOT_UA_PATTERN = new RegExp(BOTS.join('|'), 'i');
app.use(serveStatic(path.join(__dirname, 'dist')));
app.use(rendertron.makeMiddleware({
proxyUrl: 'https://xymba-renderbot.herokuapp.com/render',
userAgentPattern: BOT_UA_PATTERN
}));
app.get('/service-worker.js', (req, res) => {
res.sendFile(path.resolve(__dirname, 'dist', 'service-worker.js'));
});
app.get('*', function (req, res) {
const index = path.join(__dirname, 'dist', 'index.html')
res.sendFile(index, path.join(__dirname, 'dist/'))
})
const port = process.env.PORT || 80;
app.listen(port);
vue.config.js
const path = require("path");
module.exports = {
devServer: {
open: process.platform === 'darwin',
host: '0.0.0.0',
port: 8085, // CHANGE YOUR PORT HERE!
https: true,
hotOnly: false,
proxy: {
"^/render/": {
target: "https://xymba-renderbot.herokuapp.com/",
pathRewrite: { "^/render/": "/render/" },
changeOrigin: true,
logLevel: "debug"
}
}
}
}