From 6eb3268cbafb280e0953d48eaba77960639aa998 Mon Sep 17 00:00:00 2001 From: guumaster Date: Thu, 1 Nov 2018 12:09:50 +0100 Subject: [PATCH] add base callback url to config --- app.js | 10 +++++++--- config.sample.json | 5 +++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app.js b/app.js index 0f0c4c2..2ae2021 100644 --- a/app.js +++ b/app.js @@ -1,3 +1,4 @@ +const nconf = require('nconf') const express = require('express') const bodyParser = require('body-parser') const session = require('express-session') @@ -11,6 +12,9 @@ const socket = require('./helpers/socket') const app = express() +// load config +nconf.file({ file: 'config.json' }).env() + app.set('port', (process.env.PORT || 5000)) app.set('views', __dirname + '/views') app.set('view engine', 'ejs') @@ -64,7 +68,7 @@ app.get('/webhook/twitter', function(request, response) { app.post('/webhook/twitter', function(request, response) { console.log(request.body) - + socket.io.emit(socket.activity_event, { internal_id: uuid(), event: request.body @@ -92,14 +96,14 @@ app.get('/subscriptions', auth.basic, cacheRoute(1000), require('./routes/subscr * Starts Twitter sign-in process for adding a user subscription **/ app.get('/subscriptions/add', passport.authenticate('twitter', { - callbackURL: '/callbacks/addsub' + callbackURL: `${nconf.get('BASE_CALLBACK_URL')}/callbacks/addsub` })); /** * Starts Twitter sign-in process for removing a user subscription **/ app.get('/subscriptions/remove', passport.authenticate('twitter', { - callbackURL: '/callbacks/removesub' + callbackURL: `${nconf.get('BASE_CALLBACK_URL')}/callbacks/removesub` })); diff --git a/config.sample.json b/config.sample.json index 59ba364..62e0a87 100644 --- a/config.sample.json +++ b/config.sample.json @@ -5,5 +5,6 @@ "TWITTER_ACCESS_TOKEN_SECRET": "your-access-token-secret", "TWITTER_WEBHOOK_ENV": "env-beta", "BASIC_AUTH_USER": "admin", - "BASIC_AUTH_PASSWORD": "bluebird" -} \ No newline at end of file + "BASIC_AUTH_PASSWORD": "bluebird", + "BASE_CALLBACK_URL": "https://your.app.domain" +}