简体   繁体   中英

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. 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 > routes > tasks.js 在此处输入图片说明

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

when i go to request /tasks在此处输入图片说明

it returns a 502: Bad Gateway

Try this:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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