Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix url giving wrong signature base if used with Express app.use() #10

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

tinnou
Copy link

@tinnou tinnou commented Oct 1, 2014

If using Express 4 app.use() to mount certain routes paths, the req.url will be rewritten to reflect the mounted path. This has the effect of creating a wrong base resulting in an invalid computed signature. I changed it to use req.originalUrl since it preserves the original path.

e.g:
if you use

app.use('/users', users)

and in your users module you have

   /\* GET user by Id. */
    router.get('/:id',
        passport.authenticate('consumer', { session: false }),
        function (req, res) {
            console.log("Authenticated!");
    });

The req.url will be set to http://domain/12345 whereas req.original will be http://domain/users/12345

If using Express 4 `app.use()` to mount certain routes paths, the req.url will be rewritten to reflect the mounted path. This has the effect of creating a wrong base resulting in an invalid computed signature. I changed to use `req.originalUrl` since it preserves the original path.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant