Skip to content

Instantly share code, notes, and snippets.

@iamblue
Created February 27, 2014 04:55
Show Gist options
  • Select an option

  • Save iamblue/9244610 to your computer and use it in GitHub Desktop.

Select an option

Save iamblue/9244610 to your computer and use it in GitHub Desktop.
use nodejs middleware to seperate SEO source
app.use(function(req, res, next) {
var frag = req.query._escaped_fragment_;
if (!frag) return next();
if (frag){
//處理指向的對應route
}
try {
var file = __dirname + "/snapshots" + frag;
res.sendfile(file);
} catch (err) {
res.send(404);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment