Node.js Express serving index.html instead of static file -


im starting node.js express app, using angular. working fine while creating app on cloud9.

i released app on ec2 instance , node deliver index.html instead of static file... when in chrome debug network, see js files loaded (status 200) when preview them, index.html file... type of js files set text/html...

here little server.js (no routing fake angular data, no call server now...)

var express = require('express'), path = require('path'), http = require('http'), fs = require('fs');  var app = express();  var logfile = fs.createwritestream('./logger/express.log', {flags: 'a'}); //use {flags: 'w'} open in write mode  app.configure(function () {     app.set('port', process.env.port || 3000);     app.use(express.logger({stream: logfile}));     app.use(express.bodyparser()),     app.use(express.static(path.join(__dirname, 'public'))); });   /*app.get('/events', eventroute.getevents); app.post('/events', eventroute.saveevent);*/  http.createserver(app).listen(app.get('port'), function () {     console.log("express server listening on port " + app.get('port')); }); 

as said previously, working fine on cloud9 (cannot try on local now...).

does has clue going wrong?

thanks

dominic

ps: forgot mention same css file!

edit: here little picture of mean! enter image description here

and when @ preview of file enter image description here

edit2: deleted files , uploaded them again. same problem! need on 1 please!

fo live demo of problem, hit that site

can elaborate on mean 'static file' ?

on line:

app.use(express.static(path.join(__dirname, 'public'))); 

you have express routed serve files in 'public' dir static files. default, express.static serve 'index.html' if directory called. since you're serving 'public' dir '/', it's delivering index.html.

edit: i'm not sure if problem, part of code redundant:

http.createserver(app).listen() 

you can say:

app.listen([port], [callback]); 

since calling express() created server. hope helps.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -