I created an auth module using nestjs and two passport strategies: passport-facebook, passport-google-oauth20. Everything works fine, except when it's not
If there's an error in a passport strategy, the server return 500 error instead of a error thrown by a strategy. For example, if the token from identity provider been used already we got FacebookTokenError: This authorization code has been used. (passport-facebook) or TokenError: Bad Request (passport-google-oauth20) message in the console but server return 500 error.
What is the nestjs way to return proper errors in that case?
Also, can somebody explain why we need 2 routes (auth/google and auth/google/callback) when just one (auth/google with @UseGuards(AuthGuard('google'))) works fine?