Skip to content
This repository has been archived by the owner on Dec 27, 2022. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/0.4.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
ColinMaudry committed Nov 2, 2016
2 parents b04e987 + 09e5a17 commit 4159131
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app.js
Expand Up @@ -102,12 +102,16 @@ var accessLogStream = FileStreamRotator.getStream({
frequency: 'weekly',
verbose: false
})
app.use(morgan(':date[iso]\t:remote-addr\t:method\t:url\t:req[accept]\t:req[content-type]\t:req[content-length]\t:response-time[0]\t:status', {stream: accessLogStream}))
morgan.token('real-ip', function getRealIp (request) {
return request.headers["x-real-ip"] || request.ip;
})
app.use(morgan(':date[iso]\t:real-ip\t:method\t:url\t:req[accept]\t:req[content-type]\t:req[content-length]\t:response-time[0]\t:status', {stream: accessLogStream}))

//Home page
app.get('/', function(request,response) {
debug(request.url + " .get");
var exposed = {};
var realIp = request.headers["x-real-ip"] || request.ip;

exposed.config = JSON.parse(JSON.stringify(config.get('app')));
exposed.defaultEndpoint = defaultEndpointQuery;
Expand All @@ -117,7 +121,7 @@ app.get('/', function(request,response) {

response.expose(exposed);
response.expose('var siteRootUrl = "' + siteRootUrl + '";');
response.expose('var userIp = "' + request.ip + '";');
response.expose('var userIp = "' + realIp + '";');
response.render('index', { layout: false,userIp: request.ip, analytics: config.get("app.public.analytics") });
});

Expand Down

0 comments on commit 4159131

Please sign in to comment.