문제

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?

도움이 되었습니까?

해결책

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);

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top