diff --git a/index.js b/index.js index a09fe0c..926eb64 100644 --- a/index.js +++ b/index.js @@ -245,11 +245,11 @@ CASAuthentication.prototype._login = function(req, res, next) { // Save the return URL in the session. If an explicit return URL is set as a // query parameter, use that. Otherwise, just use the URL from the request. - req.session.cas_return_to = req.query.returnTo || url.parse(req.url).path; + req.session.cas_return_to = req.query.returnTo || url.parse(req._parsedOriginalUrl || req.url).path; // Set up the query parameters. var query = { - service: this.service_url + url.parse(req.url).pathname, + service: this.service_url + url.parse(req._parsedOriginalUrl || req.url).pathname, renew: this.renew }; @@ -300,7 +300,7 @@ CASAuthentication.prototype._handleTicket = function(req, res, next) { requestOptions.path = url.format({ pathname: this.cas_path + this._validateUri, query: { - service: this.service_url + url.parse(req.url).pathname, + service: this.service_url + url.parse(req._parsedOriginalUrl || req.url).pathname, ticket: req.query.ticket } });