问题
Front-end:
I have SPA client website that uses own routing system. For instance it has route http://localhost:8080/about
Back-end:
I'm using prerender-node on express.js server (runs on port 3001) to prerender static html for crawler bots:
app.use(require('prerender-node')
.set('prerenderServiceUrl', 'http://localhost:3000/')
.set('afterRender', function (err, req, prerender_res) {
console.log('URL: ', req.url); // here I see: "/about?_escaped_fragment_="
}));
my express routing looks like this:
router.get('*', function (req, res, next) {
res.sendFile(path.resolve('../frontend/dist/index.html'));
});
Problem:
The problem is that if I send http://localhost:3001/about?_escaped_fragment_=
to the server as a response I get static index.html home page (but I wanted to prerender about section).
As I understand prerender-node middleware doesn't know how to navigate to /about section and prerenders always home page.
Question:
How to prerender the actual about page of my SPA according to a link?
来源:https://stackoverflow.com/questions/35856296/seo-with-express-js-and-prerender-node