diff --git a/app.js b/app.js index 7a74838..5428dc5 100644 --- a/app.js +++ b/app.js @@ -6,7 +6,7 @@ var hbs = require('hbs'); var app = express(); app.set('view engine', 'hbs'); -app.set('trust proxy', 'loopback'); +app.enable('trust proxy'); function isSetup() { return (process.env.CONSUMER_KEY != null) && (process.env.CONSUMER_SECRET != null); @@ -66,8 +66,12 @@ app.get('/setup', function(req, res) { res.redirect('/'); } else { - var isRemote = (req.hostname.indexOf('localhost') != 0); - res.render('setup', { isRemote: isRemote, oauthCallbackUrl: oauthCallbackUrl(req) }); + var isLocal = (req.hostname.indexOf('localhost') == 0); + var herokuApp = null; + if (req.hostname.indexOf('.herokuapp.com') > 0) { + herokuApp = req.hostname.replace(".herokuapp.com", ""); + } + res.render('setup', { isLocal: isLocal, oauthCallbackUrl: oauthCallbackUrl(req), herokuApp: herokuApp}); } }); diff --git a/views/setup.hbs b/views/setup.hbs index 8d99e84..b54bbcc 100644 --- a/views/setup.hbs +++ b/views/setup.hbs @@ -2,7 +2,7 @@
  1. - Setup an OAUTH on Salesforce + Setup an OAUTH on Salesforce:
    1. Create a new Connected App on Salesforce
    2. Fill in the Connected App Name, API Name, and Contact Email fields.
    3. @@ -12,9 +12,16 @@
  2. - {{#if isRemote}} - Blah - {{else}} + {{#if herokuApp}} + Set the Consumer Key and Consumer Secret values in your Heroku app's config: +
      +
    1. Open your app's settings
    2. +
    3. Click Reveal Config Vars
    4. +
    5. Add a new config var named CONSUMER_KEY with the value of your Connected App's Consumer Key
    6. +
    7. Add a new config var named CONSUMER_SECRET with the value of your Connected App's Consumer Secret
    8. +
    + {{/if}} + {{#if isLocal}} Create a new .env file in the root of your project directory containing the following with your newly created Consumer Key and Consumer Secret values:
    # DO NOT SHARE THIS FILE OR PUT IT INTO YOUR SCM
     CONSUMER_KEY=YOUR_CONSUMER_KEY