Page MenuHomeDevCentral

D2189.id5506.diff
No OneTemporary

D2189.id5506.diff

diff --git a/app.js b/app.js
--- a/app.js
+++ b/app.js
@@ -20,4 +20,5 @@
module.exports = app;
-app.use('/', require('./routes'));
+const api_entry_point = process.env.API_ENTRY_POINT || '/datasources';
+app.use(api_entry_point, require('./routes'));
diff --git a/routes.js b/routes.js
--- a/routes.js
+++ b/routes.js
@@ -27,7 +27,7 @@
return datasources.map(function (item) {
return {
"description": item.description,
- "URL": base_url + item.url,
+ "URL": base_url + "/" + item.url,
};
});
}
@@ -41,7 +41,7 @@
(protocol === "https" && port !== 443);
}
-function getUrl(req) {
+function getServerUrl(req) {
const port = app.get("port");
let url = req.protocol + "://" + req.hostname;
@@ -49,19 +49,18 @@
url += ":" + port;
}
- url += req.url;
-
return url;
}
-router.get('/', function(req, res) {
- let url = getUrl(req);
+router.get("/", function(req, res) {
+ const api_entry_point = process.env.API_ENTRY_POINT || '/datasources';
+ const url = getServerUrl(req) + api_entry_point;
res.send(JSON.stringify(formatDatasources(url)));
});
datasources.forEach(function (datasource) {
- router.get('/' + datasource.url, function (req, res) {
+ router.get("/" + datasource.url, function (req, res) {
require("./controllers/" + datasource.controller)
.get(req, res);
});

File Metadata

Mime Type
text/plain
Expires
Tue, Nov 19, 02:59 (13 h, 6 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2251775
Default Alt Text
D2189.id5506.diff (1 KB)

Event Timeline