I'm attempting to deploy this application to heroku. I have successfully deployed the application to heroku and added the redirectURI to my google cloud environment.
When it comes to logging in through Oauth, I receive the error "Error 400: redirect_uri_mismatch". This is because heroku listens for an HTTP request and not an HTTPS request, and google requires HTTPS when in production.
I have changed the callbackURI in /config/passport.js to force HTTP when in production, and changed proxy to true:
const GoogleStrategy = require("passport-google-oauth20").Strategy
const mongoose = require("mongoose")
const User = require("../models/User")
module.exports = function (passport) {
if (process.env.NODE_ENV === "development") {
passport.use(new GoogleStrategy({
clientID: process.env.GOOGLE_CLIENT_ID,
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
callbackURL: "http://localhost:3000/auth/google/callback",
proxy: true
},
// original params
} else {
passport.use(new GoogleStrategy({
clientID: process.env.GOOGLE_CLIENT_ID,
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
callbackURL: "http://polar-forest-68113.herokuapp.com/auth/google/callback",
proxy: true
},
// original params
}