node.js - Express.js app frequently doesn't load new route without hard refresh? -
i'm experiencing strange issue. when navigate page page in express.js app (currently have 3 pages: home, about, contact), page appears blank. when hard refresh on mac (shift command r) of assets load in. when @ networks tab in chrome dev tools, appears if assets loading in -- don't see 404's.
here screenshot of app directory see i'm working with: http://d.pr/i/lqlv
also, here app.js file:
var express = require('express') , partials = require('express-partials') , app = express(); app.configure(function() { app.set('title', ' | todo app'); app.set('view engine', 'ejs'); app.use(express.static(__dirname + '/public')); app.set('views', __dirname + '/views'); app.use(partials()); }); app.get('/', function(request, response, next) { response.render('index', { title: "home" + app.get('title') }); }); app.get('/home', function(request, response, next) { response.redirect('/'); }); app.get('/about', function(request, response) { response.render('about', { title: "about" + app.get('title') }); }); app.get('/contact', function(request, response) { response.render('contact', { title: "contact" + app.get('title') }); }); app.use(function(request, response){ response.render('404', { title: "404" + app.get('title') }); }); app.listen(3000);
you not using app.router
, handles routes:
app.use(app.router); app.get('/', function(req,res,next){ res.render('index'); });
Comments
Post a Comment