Skip to content

Prefix URL affects the redirected URL #316

Description

@ssuriyayuvan

grant config

app.use(grant({
  defaults: {
   "protocol": "http",
    "host": "localhost:5001",
    "prefix": "",  // Leave prefix empty to avoid '/auth/' prefix for other routes
    "transport": "session",
    "state": true,
    "response": "json",
    "debug": true
  },
  discord: {
    key: process.env.DISCORD_CLIENT_KEY,
    secret: process.env.DISCORD_SECRET_KEY,
    scope: ['identify', 'email'],
    callback: '/auth/discord/callback'
  },
  twitter: {
    key: process.env.TWITTER_CONSUMER_KEY,
    secret: process.env.TWITTER_CONSUMER_SECRET,
    callback: '/auth/twitter/callback',
    scope: ['users.read']
  },
  google: {
    key: process.env.GOOGLE_CLIENT_ID,
    secret: process.env.GOOGLE_CLIENT_SECRET,
    scope: ['profile', 'email'],
    callback: '/auth/google/callback'
  }
}));

redirect URL

app.get('/auth/:provider/callback', (req, res) => {
  console.log("Req Query", req.query);
  const { provider } = req.params;
  res.send('Hello World!')
});

Incoming redirected requests are affected by the default prefix. If we give /auth as a prefix then it will block the redirect URL /auth/:provider/callback and if we leave this as empty then it sends undefined in the callback URL.

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