Skip to content

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

Open
tinnou wants to merge 2 commits into
jaredhanson:masterfrom
tinnou:patch-1
Open

tinnou wants to merge 2 commits into
jaredhanson:masterfrom
tinnou:patch-1

Conversation

@tinnou

@tinnou tinnou commented Oct 1, 2014

Copy link
Copy Markdown

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

tinnou added 2 commits October 1, 2014 00:16
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.

1 participant