Forward request to alternate request handler instead of redirect

前端 未结 7 2141
借酒劲吻你
借酒劲吻你 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:07

    You can use run-middleware module exactly for that. Just run the handler you want by using the URL & method & data.

    https://www.npmjs.com/package/run-middleware

    For example:

    app.runMiddleware('/get-user/20',function(code,body,headers){
        res.status(code).send(body)
    })
    

提交回复
热议问题