2014-03-29 121 views
1

我剛剛下載並開始玩MEAN堆棧(https://github.com/linnovate/mean),一切正常,直到我嘗試和其他路線。MEAN堆棧路由問題

//app/routes/hello.js: 

'use strict'; 
module.exports = function(app, passport) { 
    app.get('/hello', function(req, res, next, id) { 
     console.log(req); 
     res.json(123456); 
    }); 
}; 

如果我登錄到app.routes我可以看到路線:

{ path: '/hello', 
    method: 'get', 
    callbacks: [Object], 
    keys: [], 
    regexp: /^\/hello\/?$/i 
} 

我曾試圖向捲曲

curl http://localhost:3000/hello -Method GET 

我得到404

但是,如果我get/articles(這是MEAN.IO中的示例路線之一)

curl http://localhost:3000/articles -Method GET 

它工作得很好。 現在坐了幾個小時,真的看不到任何路線設置的差異。但包括默認作品,所有路線我嘗試添加自己呈現404.

因此總結,清理MEAN.IO叉。默認路由工作,線路添加,結果在404

回答

1

路由配置更改爲:

'use strict'; 
module.exports = function(app, passport) { 
    app.get('/hello', function(req, res) { 
     console.log(req); 
     res.json(123456); 
    }); 
}; 

使它工作,真的不知道是什麼原因。