Howdy! I had everything working great in my localhost setup. Unfortunately when I moved to testing using a public-facing URL attempting to login went to my site rather than Google's causing a 404. I am hosting this dev site as https://swift.saisquared.dev/ which uses IIS to reverse proxy to the original localhost environment http://localhost:3940. Because of this setup you can view the site on the server using either address, but only the latter actually lets you log in.
If you were to go to the live site now https://swift.saisquared.dev/ and click the Login button you would get my 404 page. In the console you would see Fastify's logger display:
07/13/24 00:14:18 info: #req-s ←GET:/login request from ip ::1 (fastify-request-logger)
07/13/24 00:14:18 info: #req-s →GET:/login response with a 302-status took 4.166ms (fastify-request-logger)
07/13/24 00:14:18 warn: #req-t →GET:/o/oauth2/v2/auth?response_type=code&redirect_uri=https%3A%2F%2Fswift.saisquared.dev%2Fapi%2Fauth%2Fgoogle%2Fcallback&scope=profile%20email&client_id=294398145538-hm97gsnslbpdi47or8csqlaoic51dcrt.apps.googleusercontent.com response with a 404-status took 16.287ms (fastify-request-logger)
However if I'm on that server and go to http://localhost:3940 (which serves up the identical site) and click the Login button it goes ahead to Google to choose an account and the Fastify log shows:
07/13/24 00:14:46 info: #req-13 ←GET:/login request from ip ::1 (fastify-request-logger)
07/13/24 00:14:46 info: #req-13 →GET:/login response with a 302-status took 1.635ms (fastify-request-logger)
Somehow, be it the reverse proxy or some other thing happening in the middle Passport is choosing to call my server for the Google login page rather than Google as it should.
I did a lot of searching and could not find a similar problem but given all the variables it seems like there would be a simple solution. Would really appreciate some help as the next step is to deploy to the real website.
P.S. I went so far as trying to do this with @fastify/oauth2 before asking for help and it produces the same result, everything works access the site using localhost but not with swift.saisquared.dev.
Sorry for the trouble, it was my fault related to outbound redirects from IIS, just needed to change one option on the server and everything is working.
💬 Question here
Howdy! I had everything working great in my localhost setup. Unfortunately when I moved to testing using a public-facing URL attempting to login went to my site rather than Google's causing a 404. I am hosting this dev site as https://swift.saisquared.dev/ which uses IIS to reverse proxy to the original localhost environment http://localhost:3940. Because of this setup you can view the site on the server using either address, but only the latter actually lets you log in.
If you were to go to the live site now https://swift.saisquared.dev/ and click the Login button you would get my 404 page. In the console you would see Fastify's logger display:
With this debug information:
However if I'm on that server and go to http://localhost:3940 (which serves up the identical site) and click the Login button it goes ahead to Google to choose an account and the Fastify log shows:
So you can see when someone is at https://swift.saisquared.dev/ and Login is clicked the URL changes to
rather than the URL http://localhost:3940 changes to
Somehow, be it the reverse proxy or some other thing happening in the middle Passport is choosing to call my server for the Google login page rather than Google as it should.
I did a lot of searching and could not find a similar problem but given all the variables it seems like there would be a simple solution. Would really appreciate some help as the next step is to deploy to the real website.
P.S. I went so far as trying to do this with
@fastify/oauth2
before asking for help and it produces the same result, everything works access the site using localhost but not with swift.saisquared.dev.Your Environment