Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F12239674
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/routes.js b/routes.js
index 7bb2db4..3bd3fe0 100644
--- a/routes.js
+++ b/routes.js
@@ -1,69 +1,73 @@
/* -------------------------------------------------------------
Nasqueron API - datasources
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Author: Sébastien Santoro aka Dereckson
Licence: BSD-2-Clause
------------------------------------------------------------- */
"use strict";
const express = require('express');
const router = express.Router();
const app = require('./app');
/* -------------------------------------------------------------
Datasources
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
const datasources = [
{
url: "/dev/openfire/changelog",
controller: "/dev/openfire/changelog.js",
description: "Openfire changelog",
},
];
function formatDatasources(base_url) {
return datasources.map(function (item) {
return {
"description": item.description,
"URL": base_url + item.url,
};
});
}
/* -------------------------------------------------------------
Routes
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
-function isPortRequired(protocol, port) {
+function isPortRequired(protocol, forwardedProtocol, port) {
+ if (forwardedProtocol === "https") {
+ return port !== 80 && port !== 443;
+ }
+
return (protocol === "http" && port !== 80) ||
(protocol === "https" && port !== 443);
}
function getServerUrl(req) {
const port = app.get("port");
let url = req.protocol + "://" + req.hostname;
- if (isPortRequired(req.protocol, port)) {
+ if (isPortRequired(req.protocol, req.get('X-Forwarded-Proto'), port)) {
url += ":" + port;
}
return url;
}
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) {
require("./controllers/" + datasource.controller)
.get(req, res);
});
});
module.exports = router;
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sat, Oct 11, 23:38 (1 d, 2 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3064257
Default Alt Text
(2 KB)
Attached To
Mode
rAPIDS Nasqueron API datasources
Attached
Detach File
Event Timeline
Log In to Comment