Domanda

I have Backbone powered single page app. App consists of couple of files:

index.html
javascripts/app.js
javascripts/vendor.js
stylesheets/app.css
images/ -> image assets

I want to add prerender.io service to my app to make it SEO-friendly. The easiest way of doing this for me is to use express.js hosted on heroku:

var express = require('express');
var app = express();
app.use(require('prerender-node').set('prerenderToken', 'YOUR_TOKEN'));
// ...
app.listen(process.env.PORT || 5000);

But maybe express or actually node are not best for serving static files? Maybe heroku isn't best for serving static files? What will be best solution? What do you recommend?

È stato utile?

Soluzione

See this StackOverflow question for serving static files through expressjs: static files with express.js

You should be able to use Heroku's free dyno to handle a good bit of traffic since you're only serving static files.

I would suggest putting all of those files/folder in a "public/" directory and using this code:

var express = require('express'); 
var app = express();
app.use(express.static(__dirname + '/public'));

app.listen(process.env.PORT || 3000);

Altri suggerimenti

You better use CDN for serving static files like Amazon S3.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top