title: Unable to login with Google OAuth when deployed to Heroku
body: <p>I am unable to login to the app when deployed to Heroku.  I had a successful build and deployment, but when I launch the app it starts me logged out and upon attempting to login, it hangs and throws an Application error.
  Express/Passport/MongoDB + create-react-app</p>
  
  <p>I chek my keys several time, everesting match perfect. On my localserver everesing working perfect. Can it be a problem with "https" response on server?</p>
  
  <p>app link  <a href="https://mysterious-thicket-20426.herokuapp.com/" rel="nofollow noreferrer">https://mysterious-thicket-20426.herokuapp.com/</a></p>
  
  <p>git repo <a href="https://github.com/detoner777/email-feedback-app" rel="nofollow noreferrer">https://github.com/detoner777/email-feedback-app</a></p>
  
  <p>heroku err logs:</p>
  
  <p>2019-08-20T09:44:08.211815+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/auth/google/callback?code=4%2FpAFASjHeS_JuqGKXbEIDY4Jh5zHBJZk-Zyg19q6DHWGVtuipmCKVt1hLpwKltJUHW9XB3EBLcPGorEQUI68uZCE&amp;scope=email+profile+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile&amp;authuser=0&amp;session_state=330af188f3789437fd21ab099ebe776784cfe500..3fb5&amp;prompt=none" host=mysterious-thicket-20426.herokuapp.com request_id=59b62556-d07c-42ae-8f7f-e89b3ab5b735 fwd="31.134.127.229" dyno=web.1 connect=1ms service=30000ms status=503 bytes=0 protocol=https
  2019-08-20T09:52:03.838240+00:00 heroku[router]: at=info method=HEAD path="/" host=mysterious-thicket-20426.herokuapp.com request_id=81a31581-1aa6-478d-98af-68b6c479e32a fwd="217.182.175.162" dyno=web.1 connect=0ms service=1ms status=200 bytes=289 protocol=https</p>
  
  <pre><code>//inex.js
  const express = require('express');
  const mongoose = require('mongoose');
  const cookieSession = require('cookie-session');
  const passport = require('passport');
  const bodyParser = require('body-parser');
  const keys = require('./config/keys');
  require('./models/User');
  require('./services/passport');
  
  mongoose.connect(keys.mongoURI);
  
  const app = express();
  
  app.use(bodyParser.json());
  app.use(
      cookieSession({
          maxAge: 30 * 24 * 60 * 60 * 1000,
          keys: [keys.cookieKey]
      })
  );
  
  
  app.use(passport.initialize());
  app.use(passport.session());
  
  require('./routes/authRoutes')(app);
  require('./routes/billingRoutes')(app);
  
  
  if (process.env.NODE_ENV === 'production') {
      app.use(express.static('client/build'));
      const path = require('path');
      app.get('*', (req, res) =&gt; {
          res.sendFile(path.resolve(__dirname, 'client', 'build', 'index.html'));
      });
  }
  
  const PORT = process.env.PORT || 5000;
  app.listen(PORT);
  
  
  // passport.js
  const passport = require('passport');
  const GoogleStrategy = require('passport-google-oauth20').Strategy;
  const mongoose = require('mongoose');
  const keys = require('../config/keys');
  
  const User = mongoose.model('users');
  
  passport.serializeUser((user, done) =&gt; {
      done(null, user.id);
  });
  
  passport.deserializeUser((id, done) =&gt; {
      User.findById(id).then(user =&gt; {
          done(null, user);
      });
  });
  
  passport.use(
      new GoogleStrategy(
          {
              clientID: keys.googleClientID,
              clientSecret: keys.googleClientSecret,
              callbackURL: '/auth/google/callback',
              proxy: true
          },
          async (accessToken, refreshToken, profile, done) =&gt; {
              const existingUser = await User.findOne({ googleId: profile.id });
  
              if (existingUser) {
                  return done(null, existingUser);
              }
  
              const user = await User({ googleID: profile.id }).save()
              done(null, user);
          }
      )
  );
  </code></pre>