Forward request to alternate request handler instead of redirect

前端 未结 7 2132
借酒劲吻你
借酒劲吻你 2020-12-07 22:24

I\'m using Node.js with express and already know the existence of response.redirect().

However, I\'m looking for more of a forward() funct

7条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-07 23:03

    Using the next function does not work if the next handler is not added in the right order. Instead of using next, I use the router to register the handlers and call

    router.get("/a/path", function(req, res){
        req.url = "/another/path";
        router.handle(req, res);
    }
    

提交回复
热议问题