Skip to content

Commit

Permalink
feat(messenger): get hostname from BOTPRESS_URL (resolve #910) (#997)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmytropanontko authored and epaminond committed Oct 10, 2018
1 parent c671043 commit 3f9ddda
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/channels/botpress-channel-messenger/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ const initializeMessenger = async (bp, configurator) => {
.catch(err => bp.logger.error(err))
}

let hostname = []
const defaultHostname =
process.env.BOTPRESS_URL && process.env.NODE_ENV === 'production'
? (hostname = process.env.BOTPRESS_URL.match(/https:\/\/(.*?)\//)) && hostname[1]
: ''

module.exports = {
config: {
applicationID: { type: 'string', required: true, default: '', env: 'MESSENGER_APP_ID' },
Expand All @@ -66,7 +72,7 @@ module.exports = {
verifyToken: { type: 'string', required: false, default: '', env: 'MESSENGER_VERIFY_TOKEN' },
enabled: { type: 'bool', required: true, default: true },
enableAllProfileFields: { type: 'bool', required: true, default: false },
hostname: { type: 'string', required: false, default: '', env: 'MESSENGER_HOST' },
hostname: { type: 'string', required: false, default: defaultHostname, env: 'MESSENGER_HOST' },

graphVersion: { type: 'string', required: true, default: '2.12' },
displayGetStarted: { type: 'bool', required: false, default: true },
Expand Down

0 comments on commit 3f9ddda

Please sign in to comment.