How to Resolve redirect_uri_mismatch Error When Enabling Google Login in Discourse with Reverse Proxy Setup?

I created a forum using Discourse and assigned it a private domain, forums-test.com, on Server A. Then, on Server B (with the domain test.com), I set up a reverse proxy using Nginx. All accesses to test.com/forums/ are passed to forums-test.com on Server A. Additionally, on Server B, I configured response rewriting so that all links pointing to forums-test.com are replaced with test.com/forums/. Everything works correctly, but when I tried to enable Google authentication for the forum, I encountered an issue where Google returned a redirect_uri_mismatch error. This error occurs because, after Google completes verification, it attempts to call test.com/forums/auth/google_oauth2/callback to pass a temporary token to Discourse. However, during the data exchange between Discourse and Google, Discourse sends the callback URL as forums-test.com/auth/google_oauth2/callback, causing the mismatch. This outgoing request is initiated from Server A, and I cannot modify it. How can I solve this issue?

In your Google Cloud settings, what if you changed the url to forums-test.com/auth/google_oauth2/callback?

1 Like

the domain"forums-test.com" is inaccessiable in public network, so in my google cloud, i set it to test.com/auth/google_oauth2/callback

1 Like