Revert "Remove legacy /sioconfig and user agreement link"
ACP has a dependency on `/sioconfig`. Reverting until that can be
fixed.
This reverts commit a48cab81b9.
This commit is contained in:
parent
cacde7f72d
commit
cc69b3c225
5 changed files with 148 additions and 1 deletions
|
|
@ -76,6 +76,43 @@ function redirectHttps(req, res) {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Legacy socket.io configuration endpoint. This is being migrated to
|
||||
* /socketconfig/<channel name>.json (see ./routes/socketconfig.js)
|
||||
*/
|
||||
function handleLegacySocketConfig(req, res) {
|
||||
if (/\.json$/.test(req.path)) {
|
||||
res.json(Config.get('sioconfigjson'));
|
||||
return;
|
||||
}
|
||||
|
||||
res.type('application/javascript');
|
||||
|
||||
var sioconfig = Config.get('sioconfig');
|
||||
var iourl;
|
||||
var ip = req.realIP;
|
||||
var ipv6 = false;
|
||||
|
||||
if (net.isIPv6(ip)) {
|
||||
iourl = Config.get('io.ipv6-default');
|
||||
ipv6 = true;
|
||||
}
|
||||
|
||||
if (!iourl) {
|
||||
iourl = Config.get('io.ipv4-default');
|
||||
}
|
||||
|
||||
sioconfig += 'var IO_URL=\'' + iourl + '\';';
|
||||
sioconfig += 'var IO_V6=' + ipv6 + ';';
|
||||
res.send(sioconfig);
|
||||
}
|
||||
|
||||
function handleUserAgreement(req, res) {
|
||||
sendPug(res, 'tos', {
|
||||
domain: Config.get('http.domain')
|
||||
});
|
||||
}
|
||||
|
||||
function initializeErrorHandlers(app) {
|
||||
app.use((req, res, next) => {
|
||||
return next(new HTTPError(`No route for ${req.path}`, {
|
||||
|
|
@ -206,7 +243,9 @@ module.exports = {
|
|||
|
||||
require('./routes/channel')(app, ioConfig, chanPath);
|
||||
require('./routes/index')(app, channelIndex, webConfig.getMaxIndexEntries());
|
||||
app.get('/sioconfig(.json)?', handleLegacySocketConfig);
|
||||
require('./routes/socketconfig')(app, clusterClient);
|
||||
app.get('/useragreement', handleUserAgreement);
|
||||
require('./routes/contact')(app, webConfig);
|
||||
require('./auth').init(app);
|
||||
require('./account').init(app, globalMessageBus);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue