mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-07-05 21:58:58 +02:00
Merge remote-tracking branch 'origin/master' into develop
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
var os = require('os');
|
||||
|
||||
var meta = require('../meta');
|
||||
|
||||
module.exports = function (middleware) {
|
||||
@@ -15,6 +17,10 @@ module.exports = function (middleware) {
|
||||
headers['Access-Control-Allow-Origin'] = encodeURI(meta.config['access-control-allow-origin']);
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
headers['X-Upstream-Hostname'] = os.hostname();
|
||||
}
|
||||
|
||||
for (var key in headers) {
|
||||
if (headers.hasOwnProperty(key) && headers[key]) {
|
||||
res.setHeader(key, headers[key]);
|
||||
|
||||
@@ -211,7 +211,7 @@ middleware.templatesOnDemand = function (req, res, next) {
|
||||
if (!filePath.endsWith('.js')) {
|
||||
return next();
|
||||
}
|
||||
|
||||
var tplPath = filePath.replace(/\.js$/, '.tpl');
|
||||
if (workingCache[filePath]) {
|
||||
workingCache[filePath].push(next);
|
||||
return;
|
||||
@@ -234,12 +234,9 @@ middleware.templatesOnDemand = function (req, res, next) {
|
||||
}
|
||||
|
||||
workingCache[filePath] = [next];
|
||||
fs.readFile(filePath.replace(/\.js$/, '.tpl'), 'utf8', cb);
|
||||
fs.readFile(tplPath, 'utf8', cb);
|
||||
},
|
||||
function (source, cb) {
|
||||
if (!source) {
|
||||
return cb(new Error('[[error:templatesOnDemand.source-template-empty]]'));
|
||||
}
|
||||
Benchpress.precompile({
|
||||
source: source,
|
||||
minify: global.env !== 'development',
|
||||
@@ -247,7 +244,7 @@ middleware.templatesOnDemand = function (req, res, next) {
|
||||
},
|
||||
function (compiled, cb) {
|
||||
if (!compiled) {
|
||||
return cb(new Error('[[error:templatesOnDemand.compiled-template-empty]]'));
|
||||
return cb(new Error('[[error:templatesOnDemand.compiled-template-empty, ' + tplPath + ']]'));
|
||||
}
|
||||
fs.writeFile(filePath, compiled, cb);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user