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: in case there is a port number other than 80 or 443 #713

Closed
wants to merge 1 commit into from

Conversation

mihui
Copy link

@mihui mihui commented Oct 21, 2024

const strategy = new Strategy({
  config: myConfig, scope: myScope,
  callbackURL: 'https://localhost:8080/callback',
}, myVerifyFunc);

// serializeUser, deserializeUser, etc...

passport.use('my-strategy', strategy);

When the callback request reach to the callback URL, it says:

CSIAQ0167E The redirection URI that is provided in the request [https://localhost/callback] is either invalid, or does not meet the matching criteria for the registered redirection URI.

Apparently the port number is missing...

@panva
Copy link
Owner

panva commented Oct 21, 2024

Are you using express@5? Because AFAICT req.host is fixed in express 5 and properly returns port.

If you don't use the latest express version where this is fixed or use some other non-standard setup - you can just overload the currentUrl Strategy instance/prototype method so that it works for your conditions, that's the whole reason why this method is public and typed - so that you can control it.

@mihui
Copy link
Author

mihui commented Oct 22, 2024

OK, sounds good. BTW I am using "express": "^4.21.1"

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.

2 participants