简体   繁体   English

Node.js/Express.js/consign(): 默认请求有效 ("/") 但 ("/tasks") 返回 502:Bad Gateway

[英]Node.js/Express.js/consign(): default request works ("/") but ("/tasks") returns a 502:Bad Gateway

while the code is able to request successfully an app.get ("/")however, when I tried to request an app.get("/tasks"), it fails and instead returns a 502:Bad Gateway.虽然代码能够成功请求 app.get ("/") 但是,当我尝试请求 app.get("/tasks") 时,它失败并返回 502:Bad Gateway。 I've checked the yarn logs and there is no error showing.我检查了纱线日志,没有显示错误。 below are my code artifacts and live code.下面是我的代码工件和实时代码。 live code: sandbox实时代码:沙盒

Project Folder structure:项目文件夹结构: 在此处输入图片说明

src > models > tasks.js file: src > 模型 > tasks.js 文件: 在此处输入图片说明

src > routes > tasks.js src > 路线 > tasks.js 在此处输入图片说明

src > index.js:源代码> index.js: 在此处输入图片说明

when i go to request /tasks当我去请求/任务时在此处输入图片说明

it returns a 502: Bad Gateway它返回 502: Bad Gateway

Try this:尝试这个:

consign({ cwd: "src" })
  .include("./models")
  .then("./libs")
  .then("./routes")
  .into(app);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM