Quick workaround for heroku + cloudflare https problem
This commit is contained in:
parent
a2043f3fce
commit
d7823c3176
7 changed files with 12 additions and 26 deletions
7
app.js
7
app.js
|
@ -4,7 +4,6 @@ const logger = require('morgan');
|
|||
const cookieParser = require('cookie-parser');
|
||||
const bodyParser = require('body-parser');
|
||||
const sassMiddleware = require('node-sass-middleware');
|
||||
const protocol = require("./src/utils/connection");
|
||||
// const favicon = require('serve-favicon');
|
||||
|
||||
const subdomain = require('express-subdomain');
|
||||
|
@ -38,9 +37,9 @@ app.use(express.static(path.join(__dirname, 'public')));
|
|||
|
||||
app.use((req, res, next) => {
|
||||
res.locals.userInfo = require('./data/api/ListaUczniow')[1];
|
||||
res.locals.uonetplusUrl = protocol(req) + "://" + req.get('host').replace("uonetplus-opiekun", "uonetplus");
|
||||
res.locals.currentHost = protocol(req) + "://" + req.get('host');
|
||||
res.locals.mainHost = protocol(req) + "://" + req.get('host')
|
||||
res.locals.uonetplusUrl = "//" + req.get('host').replace("uonetplus-opiekun", "uonetplus");
|
||||
res.locals.currentHost = "//" + req.get('host');
|
||||
res.locals.mainHost = "//" + req.get('host')
|
||||
.replace(/(api|cufs|uonetplus|uonetplus-opiekun|uonetplus-uzytkownik)\./, "");
|
||||
next();
|
||||
});
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
const router = require('express').Router();
|
||||
const protocol = require('../../utils/connection');
|
||||
|
||||
router.all("/", (req, res) => {
|
||||
let base = protocol(req) + "://" + req.get('host');
|
||||
let base = "//" + req.get('host');
|
||||
res.json({
|
||||
"status": "success",
|
||||
"start": base.replace("api.", ""),
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
const router = require('express').Router({});
|
||||
const protocol = require('../../utils/connection');
|
||||
const api = require("../../utils/api");
|
||||
|
||||
router.all("/Certyfikat", (req, res) => {
|
||||
let base = protocol(req) + "://" + req.get('host');
|
||||
let base = "//" + req.get('host');
|
||||
|
||||
// key gen
|
||||
// keytool -genkeypair -keystore myKeystore.p12 -storetype PKCS12 -storepass 012345678901234567890123456789AB -alias LoginCert -keyalg RSA -keysize 2048 -sigalg SHA1WithRSA -validity 99999 -dname "CN=Wulkanowy, OU=Wulkanowy, O=Wulkanowy, L=Jaroslaw, ST=podkarpackie, C=WLKNW" -ext san=dns:fakelog.cf,dns:localhost,ip:127.0.0.1
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
const express = require('express');
|
||||
const fs = require('fs');
|
||||
const router = express.Router();
|
||||
const protocol = require('../utils/connection');
|
||||
|
||||
router.get("/", (req, res) => {
|
||||
res.redirect("/Default/Account/LogOn");
|
||||
|
@ -23,8 +22,8 @@ router.post("/Default/Account/LogOn", (req, res) => {
|
|||
res.cookie("ARR_cufs.vulcan.net.pl", "1234567891012131314151617181920212223242526272829303132333435363");
|
||||
return res.redirect("/Default/FS/LS?" +
|
||||
"wa=wsignin1.0&" +
|
||||
"wtrealm=" + protocol(req) + "%3a%2f%2fuonetplus.fakelog.localhost%3A300%2fdemo123%2fLoginEndpoint.aspx&" +
|
||||
"wctx=" + protocol(req) + "%3a%2f%2fuonetplus.fakelog.localhost%3A300%2fdemo123%2fLoginEndpoint.aspx");
|
||||
"wtrealm=%2f%2fuonetplus.fakelog.localhost%3A300%2fdemo123%2fLoginEndpoint.aspx&" +
|
||||
"wctx=%2f%2fuonetplus.fakelog.localhost%3A300%2fdemo123%2fLoginEndpoint.aspx");
|
||||
}
|
||||
|
||||
res.render("login-form", {title: "Logowanie (Default)", message: "Zła nazwa użytkownika lub hasło"});
|
||||
|
@ -33,7 +32,7 @@ router.post("/Default/Account/LogOn", (req, res) => {
|
|||
router.get("/Default/FS/LS", (req, res) => {
|
||||
res.render("login-cert", {
|
||||
cert: fs.readFileSync("public/cert.xml", "utf8"),
|
||||
uonetplusOpiekun: protocol(req) + "://" + req.get('host').replace("cufs.", "uonetplus.")
|
||||
uonetplusOpiekun: "//" + req.get('host').replace("cufs.", "uonetplus.")
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const protocol = require('../utils/connection');
|
||||
const {format, fromUnixTime, getYear, addYears, addMonths} = require('date-fns');
|
||||
|
||||
router.get("/", (req, res) => {
|
||||
const base = protocol(req) + "://" + req.get('host') + "/Default/123456";
|
||||
const base = "//" + req.get('host') + "/Default/123456";
|
||||
res.json({
|
||||
status: "sucess",
|
||||
data: {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const protocol = require('../utils/connection');
|
||||
|
||||
router.get("/", (req, res) => {
|
||||
res.render("log-exception", {
|
||||
|
@ -24,7 +23,7 @@ router.all("/Default/LoginEndpoint.aspx", (req, res) => {
|
|||
return res.redirect("/Default/?login=true");
|
||||
}
|
||||
|
||||
res.redirect(protocol(req) + "://" + req.get('host').replace("uonetplus", "cufs") + "/Default/Account/LogOn");
|
||||
res.redirect("//" + req.get('host').replace("uonetplus", "cufs") + "/Default/Account/LogOn");
|
||||
});
|
||||
|
||||
router.post("(/*)?", (req, res) => {
|
||||
|
@ -36,8 +35,8 @@ router.post("(/*)?", (req, res) => {
|
|||
router.get("/Default/Start.mvc/Index", (req, res) => {
|
||||
res.render("homepage", {
|
||||
title: "Uonet+",
|
||||
uonetplusOpiekun: protocol(req) + "://" + req.get('host').replace("uonetplus", "uonetplus-opiekun"),
|
||||
uonetplusUczen: protocol(req) + "://" + req.get('host').replace("uonetplus", "uonetplus-uczen")
|
||||
uonetplusOpiekun: "//" + req.get('host').replace("uonetplus", "uonetplus-opiekun"),
|
||||
uonetplusUczen: "//" + req.get('host').replace("uonetplus", "uonetplus-uczen")
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
function getProtocol(req) {
|
||||
let proto = req.connection.encrypted ? 'https' : 'http';
|
||||
// only do this if you trust the proxy
|
||||
proto = req.headers['x-forwarded-proto'] || proto;
|
||||
return proto.split(/\s*,\s*/)[0];
|
||||
}
|
||||
|
||||
module.exports = getProtocol;
|
Loading…
Reference in a new issue