forked from auth0-extensions/auth0-sso-dashboard-extension
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webtask.js
27 lines (22 loc) · 860 Bytes
/
webtask.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const url = require('url');
const tools = require('auth0-extension-express-tools');
const expressApp = require('./server');
const config = require('./server/lib/config');
const logger = require('./server/lib/logger');
const webtask = require('./server/lib/webtask');
tools.urlHelpers.getBaseUrl = (req) => {
const originalUrl = url.parse(req.originalUrl || '').pathname || '';
return url.format({
protocol: 'https',
host: req.headers.host,
pathname: originalUrl.replace(req.path, '').replace(/\/$/g, '')
});
};
const createServer = tools.createServer((cfg, storage) => {
logger.info('Starting SSO Dashboard Extension - Version:', process.env.CLIENT_VERSION);
return expressApp(cfg, storage);
});
module.exports = (context, req, res) => {
config.setValue('PUBLIC_WT_URL', webtask.getUrl(req));
createServer(context, req, res);
};