S
S
shamshudinov2015-01-08 13:57:31
Angular
shamshudinov, 2015-01-08 13:57:31

Node.js + Express4 + Angular.js indexing (static pages)?

Colleagues!
The first project in this bundle.
It came to working with bots of search engines and social networks.
This option came to mind:

var express = require('express');
var app = express();

var UAParser = require('ua-parser');

var routes = require('./routes/index');
var staticRoute = require('./routes/test');

var UACheck = function (req, res) {
    var ua = req.headers['user-agent'];
    ua = UAParser.parseUA(ua)['family'];
    if (ua == 'FacebookBot' || ua == 'TwitterBot' || ua == 'Googlebot' || ua == 'Other' || ua == 'Spider'
    ) {
        staticRoute(req, res);
    } else {
        routes(req, res);
    }
}

app.use('/', UACheck);

UACheck
routes - Angular application router
staticRoute - static pages will be generated here
Meaning: A person came - got an application, a bot came - got a static page.
What is the question: Does this option and its shortcomings have the right to life ?!

Answer the question

In order to leave comments, you need to log in

3 answer(s)
E
Eugene, 2015-01-08
@Nc_Soft

We use a govnular to generate separate pages for bots later...

A
Alexey P, 2015-01-08
@ruddy22

working option. why not?
upd
option may help, via phantom
lawsonry.com/2014/05/diy-angularjs-seo-with-phanto...
or this option
https://github.com/steeve/angular-seo

S
smanioso, 2015-01-08
@smanioso

Use https://prerender.io

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question