在NodeJS中找不到路由器

Router not found in NodeJS

本文关键字:路由器 找不到 NodeJS      更新时间:2023-09-26

我正在研究NodeJs和localhost,但当我在azure中部署时,我会收到以下错误:

错误:找不到位于app.use.res.render.message(D:''home''site''wwwroot''app.js:43:13(在Layer.handle[as-handle_request](D:''home''site''wwwroot''node_modules''express''lib''router''Layer.js:95:5(在trim_preix(D:''home''site''wwwroot''node_modules''express''lib''router''index.js:312:13(位于D:''home''site''wwwroot''node_modules''express''lib''router''index.js:280:7位于Function.prrocess_params(D:''home''site''wwwroot''node_modules''express''lib''router''index.js:330:12(在next(D:''home''site''wwwroot''node_modules''express''lib''router''index.js:271:10(位于SessionStrategy.strategy.pass(D:''home''site''wwwroot''node_modules''password''lib''middleware''authenticate.js:318:9(在SessionStrategy.authenticate(D:''home''site''wwwroot''node_modules''passport''lib''strategies''session.js:71:10(尝试时(D:''home''site''wwwroot''node_modules''password''lib''middleware''authenticate.js:341:16(在authenticate(D:''home''site''wwwroot''node_modules''password''lib''middleware''authenticate.js:342:7(

以下是我的代码:https://gist.github.com/StephanyBatista/3a2bfdd9aa3f9b7d170f

我的疑问是,为什么这个代码在localhost中可以,而在azure中不可以?

嗯,嗯,您使用的是:

app.use(function(err, req, res, next)

定义为:

app.use(function(req, res, next)

所以next是null,因为err=req,req=res,res=next,next是空的(您已经移动了参数(。

就像您在上一个函数中使用的一样。有关中间件的更多信息,解释它为什么以这种方式工作。