问题描述:

I'm currently going through the thinkster MEAN tutorial - and really just starting to learn the stack. I was busy building in the day, and all worked fine. The moment I got home, I couldn't run anything. As use npm start, I am able to use curl GET commands to get documents through the API layer, the build itself doesn't render and I get a 404. See below:

> Not Found 404 Error: Not Found at

> C:\Users\user\Documents\Stuff\misc\AngularTutorial\MEAN-Chapterized\flapper-news\app.js:37:13

> at Layer.handle [as handle_request]

> (C:\Users\user\Documents\Stuff\misc\AngularTutorial\MEAN-Chapterized\flapper-news\node_modules\express\lib\router\layer.js:95:5)

> at trim_prefix

> (C:\Users\user\Documents\Stuff\misc\AngularTutorial\MEAN-Chapterized\flapper-news\node_modules\express\lib\router\index.js:312:13)

> at

> C:\Users\user\Documents\Stuff\misc\AngularTutorial\MEAN-Chapterized\flapper-news\node_modules\express\lib\router\index.js:280:7

> at Function.process_params

> (C:\Users\user\Documents\Stuff\misc\AngularTutorial\MEAN-Chapterized\flapper-news\node_modules\express\lib\router\index.js:330:12)

> at next

> (C:\Users\user\Documents\Stuff\misc\AngularTutorial\MEAN-Chapterized\flapper-news\node_modules\express\lib\router\index.js:271:10)

> at

> C:\Users\user\Documents\Stuff\misc\AngularTutorial\MEAN-Chapterized\flapper-news\node_modules\express\lib\router\index.js:618:15

> at next

> (C:\Users\user\Documents\Stuff\misc\AngularTutorial\MEAN-Chapterized\flapper-news\node_modules\express\lib\router\index.js:256:14)

> at Function.handle

> (C:\Users\user\Documents\Stuff\misc\AngularTutorial\MEAN-Chapterized\flapper-news\node_modules\express\lib\router\index.js:176:3)

> at router

> (C:\Users\user\Documents\Stuff\misc\AngularTutorial\MEAN-Chapterized\flapper-news\node_modules\express\lib\router\index.js:46:12)

> at Layer.handle [as handle_request]

> (C:\Users\user\Documents\Stuff\misc\AngularTutorial\MEAN-Chapterized\flapper-news\node_modules\express\lib\router\layer.js:95:5)

> at trim_prefix

> (C:\Users\user\Documents\Stuff\misc\AngularTutorial\MEAN-Chapterized\flapper-news\node_modules\express\lib\router\index.js:312:13)

> at

> C:\Users\user\Documents\Stuff\misc\AngularTutorial\MEAN-Chapterized\flapper-news\node_modules\express\lib\router\index.js:280:7

> at Function.process_params

> (C:\Users\user\Documents\Stuff\misc\AngularTutorial\MEAN-Chapterized\flapper-news\node_modules\express\lib\router\index.js:330:12)

> at next

> (C:\Users\user\Documents\Stuff\misc\AngularTutorial\MEAN-Chapterized\flapper-news\node_modules\express\lib\router\index.js:271:10)

> at SendStream.error

> (C:\Users\user\Documents\Stuff\misc\AngularTutorial\MEAN-Chapterized\flapper-news\node_modules\serve-static\index.js:121:7)

The git repo with the most recent build is here:https://github.com/Rainer88/MEAN-Chapterized.git

If you could point me in the right direction, that would be appreciated.

网友答案:

GET /home

Why 404?

Your index.js on routes folder doesn't have any configurations for GET on /home. Hence you are getting a 404. Similarly, you have no routes configured for GET on / too.

GET /

You'll get a 404 for that as well. So, you need to configure routes for those endpoints

router.get('/home', function (req, res) {
    res.send({
        msg: 'hello world from /home'
    });
});

router.get('/', function (req, res) {
    res.send({
        msg: 'hello world from at /'
    });
});
相关阅读:
Top