Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions after/routes/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
require('dotenv').config();

const extendContainer = process.env.EXTEND_CONTAINER;
const extendURL = `https://${extendContainer}.sandbox.auth0-extend.com/`;

let extendHost = 'https://sandbox.auth0-extend.com';
let extendURL = `https://${extendContainer}.sandbox.auth0-extend.com/`;

if(process.env.EXTEND_HOST) {
extendHost = process.env.EXTEND_HOST;
extendURL = extendHost.replace('https://', `https://${extendContainer}.`)+'/';
}

const extendToken = process.env.EXTEND_TOKEN;

const request = require('request');
Expand All @@ -17,7 +25,8 @@ module.exports = function(app) {
res.render('settings', {
nav:'settings',
container:extendContainer,
token:extendToken
token:extendToken,
host:extendHost
});
});

Expand All @@ -26,7 +35,6 @@ module.exports = function(app) {
// this is where - normally - a process of somesort would persist the value
// data.created is simply demonstrating a server-side change
data.created = new Date();

let options = {
method:'POST',
url:extendURL +'saveLead',
Expand All @@ -35,6 +43,7 @@ module.exports = function(app) {
};

request(options, (error, response, body) => {
console.log(body);
if(error) throw new Error(error);
res.json(body);
});
Expand Down
2 changes: 1 addition & 1 deletion after/views/settings.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<div id="extend-editor" style="height: 600px; width: 100%"></div>
<script>
ExtendEditor.create(document.getElementById('extend-editor'), {
hostUrl: 'https://sandbox.auth0-extend.com/',
hostUrl: '{{host}}',
webtaskContainer: '{{container}}',
token: '{{token}}',
webtaskName: 'saveLead',
Expand Down