This commit is contained in:
Mikołaj Pich 2019-04-09 21:19:24 +02:00
parent c54e5b9289
commit 76197018d6
No known key found for this signature in database
GPG key ID: F62B26E36D4C4BAA
3 changed files with 14 additions and 7 deletions

View file

@ -1,9 +1,14 @@
const express = require('express');
const router = express.Router();
const protocol = require("../utils/connection");
/* GET home page. */
router.get('/', (req, res) => {
res.render('index', {title: 'fake-log', domain: req.get('host')});
res.render('index', {
title: 'fake-log',
proto: protocol(req),
domain: req.get('host')
});
});
module.exports = router;

View file

@ -1,7 +1,9 @@
function getProtocol(req) {
let proto = req.connection.encrypted || process.env.SSL === 'true' ? 'https' : 'http';
console.log(`proto1: ${proto}`);
// only do this if you trust the proxy
proto = req.headers['x-forwarded-proto'] || proto;
console.log(`proto2: ${proto}`);
return proto.split(/\s*,\s*/)[0];
}

View file

@ -9,14 +9,14 @@ block content
p Welcome to #{title}!
ul
li
a(href="http://api." + domain) api
a(href=proto + "://api." + domain) api
li
a(href="http://cufs." + domain) cufs
a(href=proto + "://cufs." + domain) cufs
li
a(href="http://uonetplus." + domain + "/Default/Start.mvc/Index") uonetplus
a(href=proto + "://uonetplus." + domain + "/Default/Start.mvc/Index") uonetplus
li
a(href="http://uonetplus-uczen." + domain) uonetplus-uczen
a(href=proto + "://uonetplus-uczen." + domain) uonetplus-uczen
li
a(href="http://uonetplus-opiekun." + domain + "/Default/123456") uonetplus-opiekun
a(href=proto + "://uonetplus-opiekun." + domain + "/Default/123456") uonetplus-opiekun
li
a(href="http://uonetplus-uzytkownik." + domain) uonetplus-uzytkownik
a(href=proto + "://uonetplus-uzytkownik." + domain) uonetplus-uzytkownik