Search code examples
node.jssessionmiddlewarerestifynode.js-connect

req.originalUrl not set by Restify (it is needed by Connect session middleware)


I'm getting an error when I try to use Restify with Connect session middleware. The session middleware expects req.originalUrl but Restify doesn't set that property. (It only sets req.url.) That is causing an exception in the session code. Is there any workaround for this?


Solution

  • can you just set it yourself?

    app.use(function(req, res, next){
      req.originalUrl = req.url;
      next();
    });
    app.use(connect.session({secret:'foo'});