2

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);
    });
};

app.routes をログに記録すると、ルートが表示されます。

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

カーリングしてみた

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

私は404を取得します。

しかし、/articles (MEAN.IO のサンプル ルートの 1 つ) を取得した場合

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

それはうまく動作します。数時間座って、ルートの設定方法に違いは見られません。しかし、デフォルトで含まれているものは機能し、自分で追加しようとするすべてのルートは 404 をレンダリングします。

結論として、MEAN.IO フォークをクリーンアップします。デフォルトのルートは機能し、追加したルートは404になります。

4

2 に答える 2