MEAN堆栈路由问题
我刚下载并开始玩MEAN堆栈( https://github.com/linnovate/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); }); };
如果我loginapp.routes我可以看到路线:
{ path: '/hello', method: 'get', callbacks: [Object], keys: [], regexp: /^\/hello\/?$/i }
我曾尝试curl
curl http://localhost:3000/hello -Method GET
我得到404。
但是,如果我得到/文章(这是MEAN.IO中的示例路线之一)
curl http://localhost:3000/articles -Method GET
它工作得很好。 现在坐了几个小时,真的不知道如何设置路线的任何区别。 但包括默认作品,所有路线我尝试添加自己呈现404。
所以总结一下,干净的MEAN.IO叉子。 默认路由工作,我添加的路由,结果在404。
将路由configuration更改为:
'use strict'; module.exports = function(app, passport) { app.get('/hello', function(req, res) { console.log(req); res.json(123456); }); };
让它工作,不知道为什么。