【发布时间】:2017-11-21 05:57:30
【问题描述】:
我正在使用 Node、Express、handlebars 和 MongoDB 构建一个购物车项目。目前,当我尝试使用 Jquery 提交表单时,我的“/checkout”文件收到 404 错误。最初,我使用 return false 来阻止表单在收到数据之前提交。为了解决这个问题,我也尝试使用 event.preventDefault。在另一个论坛上,有人建议我的 crsf 保护没有正确创建令牌。我处理了路线并添加到我的视图中,最后添加了 hbs 表单。这些尝试似乎都没有解决我的问题。
这是我的要点的链接。 https://gist.github.com/Satellite9/5e4ce3de5c19cee2f355d872b6d7d3c8
这是我的浏览器发送给我的错误。
*错误:在 C:\Users\Leimamo\PhpstormProjects\untitled2\app.js:60:13 处未找到 Layer.handle [as handle_request] (C:\Users\Leimamo\PhpstormProjects\untitled2\node_modules\express\lib\router\layer.js:95:5) 在 trim_prefix (C:\Users\Leimamo\PhpstormProjects\untitled2\node_modules\express\lib\router\index.js:317:13) 在 C:\Users\Leimamo\PhpstormProjects\untitled2\node_modules\express\lib\router\index.js:284:7 在 Function.process_params (C:\Users\Leimamo\PhpstormProjects\untitled2\node_modules\express\lib\router\index.js:335:12) 接下来 (C:\Users\Leimamo\PhpstormProjects\untitled2\node_modules\express\lib\router\index.js:275:10) 在 C:\Users\Leimamo\PhpstormProjects\untitled2\node_modules\express\lib\router\index.js:635:15 接下来 (C:\Users\Leimamo\PhpstormProjects\untitled2\node_modules\express\lib\router\index.js:260:14) 在 Function.handle (C:\Users\Leimamo\PhpstormProjects\untitled2\node_modules\express\lib\router\index.js:174:3) 在路由器 (C:\Users\Leimamo\PhpstormProjects\untitled2\node_modules\express\lib\router\index.js:47:12) 在 Layer.handle [as handle_request] (C:\Users\Leimamo\PhpstormProjects\untitled2\node_modules\express\lib\router\layer.js:95:5) 在 trim_prefix (C:\Users\Leimamo\PhpstormProjects\untitled2\node_modules\express\lib\router\index.js:317:13) 在 C:\Users\Leimamo\PhpstormProjects\untitled2\node_modules\express\lib\router\index.js:284:7 在 Function.process_params (C:\Users\Leimamo\PhpstormProjects\untitled2\node_modules\express\lib\router\index.js:335:12) 接下来 (C:\Users\Leimamo\PhpstormProjects\untitled2\node_modules\express\lib\router\index.js:275:10) 在 C:\Users\Leimamo\PhpstormProjects\untitled2\app.js:51:5 在 Layer.handle [as handle_request] (C:\Users\Leimamo\PhpstormProjects\untitled2\node_modules\express\lib\router\layer.js:95:5) 在 trim_prefix (C:\Users\Leimamo\PhpstormProjects\untitled2\node_modules\express\lib\router\index.js:317:13) 在 C:\Users\Leimamo\PhpstormProjects\untitled2\node_modules\express\lib\router\index.js:284:7 在 Function.process_params (C:\Users\Leimamo\PhpstormProjects\untitled2\node_modules\express\lib\router\index.js:335:12) 接下来 (C:\Users\Leimamo\PhpstormProjects\untitled2\node_modules\express\lib\router\index.js:275:10) 在服务静态 (C:\Users\Leimamo\PhpstormProjects\untitled2\node_modules\serve-static\index.js:75:16) 在 Layer.handle [as handle_request] (C:\Users\Leimamo\PhpstormProjects\untitled2\node_modules\express\lib\router\layer.js:95:5) 在 trim_prefix (C:\Users\Leimamo\PhpstormProjects\untitled2\node_modules\express\lib\router\index.js:317:13) 在 C:\Users\Leimamo\PhpstormProjects\untitled2\node_modules\express\lib\router\index.js:284:7 在 Function.process_params (C:\Users\Leimamo\PhpstormProjects\untitled2\node_modules\express\lib\router\index.js:335:12) 接下来 (C:\Users\Leimamo\PhpstormProjects\untitled2\node_modules\express\lib\router\index.js:275:10) 在 SessionStrategy.strategy.pass (C:\Users\Leimamo\PhpstormProjects\untitled2\node_modules\passport\lib\middleware\authenticate.js:325:9) *
这是 npm 给我的错误 发布/结帐 404 206.855 ms -5424
感谢您提供的任何见解。
千里
【问题讨论】:
标签: javascript node.js http-status-code-404 express-handlebars