0

For some strange reason, some changes on my route settings (MEAN environment, Node v0.12.2 and express 4) don't show effect any more!? Particularly instructions where I respond to client requests using ".sendfile()".

app.get('/', function(req, res){
    res.sendfile("/public/index.html"); // <-- trying to exclude or change this
    console.log("debug message"); //added later, never shown!!
});

Excluding or altering the sendfile instruction in the example above doesn't change anything - index.html is alyways being delivered upon request. Not even simple debug messages like console.log are shown any more?! Here's what I checked:

  • restarted Node.js server and computer several times
  • checked for duplicates of routes.js file
  • checked for duplicates of home route ("/")
  • cleaned browser cache
  • even deleted the ENTIRE route, site still delivered upon request!?!?

Maybe there is some kind of server-side cache that needs to be wiped?! I got no idea any more of what's wrong. Suggestions anyone?

Igor P.
  • 1,407
  • 2
  • 20
  • 34
  • Have you checked the possibility of this being a client side caching? – m90 Nov 22 '15 at 11:18
  • do you have the cache in your browser disabled? – Tyler Nov 22 '15 at 11:18
  • Yes, indeed I checked that too. Updated my description. – Igor P. Nov 22 '15 at 11:22
  • Have you tried to use `res.sendFile` instead on `res.sendfile`? Also [Link](http://stackoverflow.com/questions/25463423/res-sendfile-absolute-path) about sendFile and static middleware –  Nov 22 '15 at 11:33
  • I am aware that sendfile is deprecated in the meantime and I even changed it for sendFile - no change. What really bothers me is the fact, that not even a simple console.log instruction is (as shown in the example) is shown. As is the route was never called, but the site still delivered. How can that be? – Igor P. Nov 22 '15 at 12:21

1 Answers1

0

There are changes in express 4 with respect to express 3. In express 4 we have got a new method app.route() to create chainable route handlers for a route path and a new class express.Router to create modular mountable route handlers. For more details ref: Moving to Express 4 What you can do is try using code in following order:

app.route('/')
  .get(function(req, res) {
    res.render('index');
  });

And its also good serve static files by adding:

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

Good luck...:)