Skip to content

pathname in baseURL is ignored for redirectURI  #18

Description

@opatut
{
  baseUrl: 'https://example.com/basename', 
  callbackURI: '/github/callback',
}

With that config, I get the redirect URI https://example.com/github/callback, even though it should contain the /basename. I explicitly don't want to specify /basename/github/callback as the callbackURI, because that would mount the route to that pathname, which would be available at https://example.com/basename/basename/github/callback (notice the double "basename").

I think the problem lies in the usage of url.resolve:

urlObj.pathname = url.resolve(urlObj.pathname, opts.callbackURI)

url.resolve is meant to resolve relative paths, but the callbackURI starts with a slash, so the pathname is ignored. Joining them with a / (and stripping unnecessary slashes) would be preferable in that case. Since all route mountpoints are supposed to start with a slash, we can probably just always change the behaviour and drop url.resolve entirely.

I provide a PR #19 with the suggested fix.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions