sample-oauth2-client icon indicating copy to clipboard operation
sample-oauth2-client copied to clipboard

SERVER_NAME vs HTTP_HOST in google.php

Open jrblakely opened this issue 3 years ago • 0 comments

I am using an NGINX web server with a regular expression to match multiple host names, and the SERVER_NAME returned is the regular expression, not the actual host name requested/used. This caused an interesting (to me) issue because Google of course did not like the regular expression as the redirect URI.

I fixed this for my site by changing this $baseURL = 'https://' . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF']; to this $baseURL = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];

I am not sure if this is a universally wholesome change or if it introduces problems for a different configuration. Just sharing in case it is helpful to someone else.

Thanks

jrblakely avatar Oct 28 '22 12:10 jrblakely