Re-order routes so '/' doesn't take precendence over /home; this bug fix was highly non-obvious to me.
This commit is contained in:
		
							parent
							
								
									dac79d3562
								
							
						
					
					
						commit
						f4052e5bb0
					
				
							
								
								
									
										14
									
								
								server.js
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								server.js
									
									
									
									
									
								
							@ -36,12 +36,18 @@ app.engine('hbs', hbs.express4({
 | 
			
		||||
app.set('view engine', 'hbs');
 | 
			
		||||
app.set('views', __dirname + '/views');
 | 
			
		||||
 | 
			
		||||
// temp testing for static home pages.
 | 
			
		||||
/*******************************************************************************************************
 | 
			
		||||
With this express setup, ordering of routes matters!!! It's 1st-come-1st-served.
 | 
			
		||||
If a more specific route is placed after a more general route, the general route will be chosen.
 | 
			
		||||
Not like nginx where the most specific match always wins.
 | 
			
		||||
Using express.Router() in express-4 might fix this, as would converting to hapi...
 | 
			
		||||
But, for now, order routes like this:
 | 
			
		||||
    - static routes, ordered more specific to less specific
 | 
			
		||||
    - dynamic routes, ordered more specific to less specific
 | 
			
		||||
********************************************************************************************************/
 | 
			
		||||
// temp testing for static home page.
 | 
			
		||||
app.get('/home', function(req, res) {
 | 
			
		||||
   // Even when the winston call is the only thing in here...IT NO WORKY!!!
 | 
			
		||||
   // But when I move it to be the first route in the file...IT DOES WORK!!! wtf?
 | 
			
		||||
   winston.info('GET /home');
 | 
			
		||||
   //res.status(404).send('Not found');
 | 
			
		||||
   res.render('home', {}, function(err, html) {
 | 
			
		||||
        if(err !== null) {
 | 
			
		||||
            winston.error(err);
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user