mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 19:46:01 +01:00
closes #4843
This commit is contained in:
@@ -339,6 +339,10 @@ Controllers.termsOfUse = function(req, res, next) {
|
||||
res.render('tos', {termsOfUse: meta.config.termsOfUse});
|
||||
};
|
||||
|
||||
Controllers.ping = function(req, res) {
|
||||
res.status(200).send(req.path === '/sping' ? 'healthy' : '200');
|
||||
};
|
||||
|
||||
Controllers.handle404 = function(req, res) {
|
||||
var relativePath = nconf.get('relative_path');
|
||||
var isLanguage = new RegExp('^' + relativePath + '/language/.*/.*.json');
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
var nconf = require('nconf');
|
||||
var meta = require('../meta');
|
||||
var user = require('../user');
|
||||
var translator = require('../../public/src/modules/translator');
|
||||
|
||||
|
||||
module.exports = function(middleware) {
|
||||
|
||||
@@ -15,6 +13,8 @@ module.exports = function(middleware) {
|
||||
var url = req.url.replace(nconf.get('relative_path'), '');
|
||||
|
||||
var allowedRoutes = [
|
||||
'^/ping',
|
||||
'^/sping',
|
||||
'^/login',
|
||||
'^/stylesheet.css',
|
||||
'^/favicon',
|
||||
@@ -26,8 +26,8 @@ module.exports = function(middleware) {
|
||||
'^/api/widgets/render',
|
||||
'^/language/.+',
|
||||
'^/uploads/system/site-logo.png'
|
||||
],
|
||||
render = function() {
|
||||
];
|
||||
var render = function() {
|
||||
res.status(503);
|
||||
var data = {
|
||||
site_title: meta.config.title || 'NodeBB',
|
||||
@@ -40,8 +40,9 @@ module.exports = function(middleware) {
|
||||
} else {
|
||||
res.json(data);
|
||||
}
|
||||
},
|
||||
isAllowed = function(url) {
|
||||
};
|
||||
|
||||
var isAllowed = function(url) {
|
||||
for(var x=0,numAllowed=allowedRoutes.length,route;x<numAllowed;x++) {
|
||||
route = new RegExp(allowedRoutes[x]);
|
||||
if (route.test(url)) {
|
||||
@@ -49,8 +50,9 @@ module.exports = function(middleware) {
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
isApiRoute = /^\/api/;
|
||||
};
|
||||
|
||||
var isApiRoute = /^\/api/;
|
||||
|
||||
if (isAllowed(url)) {
|
||||
return next();
|
||||
|
||||
@@ -36,6 +36,9 @@ function mainRoutes(app, middleware, controllers) {
|
||||
setupPageRoute(app, '/search/:term?', middleware, [], controllers.search.search);
|
||||
setupPageRoute(app, '/reset/:code?', middleware, [], controllers.reset);
|
||||
setupPageRoute(app, '/tos', middleware, [], controllers.termsOfUse);
|
||||
|
||||
app.get('/ping', controllers.ping);
|
||||
app.get('/sping', controllers.ping);
|
||||
}
|
||||
|
||||
function globalModRoutes(app, middleware, controllers) {
|
||||
|
||||
Reference in New Issue
Block a user