I think I managed to find the solution to your issue @gorgiselkov
I'm guessing you're using IIS but if not it might help as well.
Here:

I managed to debug what was going on and I discovered that NodeBB was doing everything correctly and that passport was working as it should, sending the right URL to redirect to, but my HTTP Reverse Proxy (In my case a IIS server) was somehow rewriting th...
faviconCommunity (community.nodebb.org)