question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dynamic callbackURL

See original GitHub issue

At the moment I have to read the host from a configuration file since my application is sitting behind a reverse proxy and thus does not have the correct host set in the request.

passport.use('google:login', new GoogleStrategy({
      clientID: <CLIENT_ID>,
      clientSecret: <CLIENT_SECRET>,
      callbackURL: host + '/auth/google/callback',
      passReqToCallback: true
    }, callback
  )
)

Is there a way to have something that looks like this?

passport.authenticate('google:login', { callbackURL: domain + '/auth/google/callback' })

Issue Analytics

  • State:open
  • Created 8 years ago
  • Reactions:2
  • Comments:8

github_iconTop GitHub Comments

1reaction
AuspeXeucommented, May 24, 2019

Alright. I figured it out. At least how it works for my setup. I am operating behind an nginx reverse proxy. I made the following two adjustments to get it to work.

  1. To the nginx proxy config add the following lines
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
  1. When creating the strategy, specify the undocumented option proxy as follows
passport.use('google:login', new GoogleStrategy({
      clientID: <CLIENT_ID>,
      clientSecret: <CLIENT_SECRET>,
      callbackURL: host + '/auth/google/callback',
      passReqToCallback: true,
      proxy: true
    }, callback
  )
)

So long…

Edit: Maybe someone could make a PR to document this option?

0reactions
AuspeXeucommented, May 24, 2019

@jkhusanov you referring to nodejs server code? I extracted the host like this:

const host = req.headers.referer.match(/^(http[s]{0,1}:\/\/[^/]*).*/)
Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I set up a dynamic Allowed Callback URL?
Solution - Single Callback URL Using State · Pass the random value as the state parameter in the authentication request to Auth0. ·...
Read more >
Dynamic Callback URL - Plugins - miniOrange
This feature allows you to specify a custom redirect URL. This URL will be sent to the server as the redirect URI parameter....
Read more >
Solving for Dynamic OAuth 2.0 Callbacks with Environment ...
In this blog post, we will discuss the concept of Environment Handles and how they can be used to support dynamic OAuth.
Read more >
jaredhanson/passport-google-oauth2 - dynamic callbackURL
Hi, Thank you for releasing an 'official' Google Oauth2 passport module. I am having some trouble trying to implement a dynamic callback URL...
Read more >
Connected App with dynamic Callback URL in managed ...
While it is not possible to have dynamic callback URL in one single Conntected App, there are at least three different approaches how...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found