diff --git a/qminingPublic/moodle-test-userscript b/qminingPublic/moodle-test-userscript index 2c815c8..f8d4bf2 160000 --- a/qminingPublic/moodle-test-userscript +++ b/qminingPublic/moodle-test-userscript @@ -1 +1 @@ -Subproject commit 2c815c8d20b6c25a4214d6118760d993f2287f36 +Subproject commit f8d4bf2a414d2973582c08bfa8b8b8f19389b2e9 diff --git a/server.js b/server.js index 1da6d70..26b7633 100755 --- a/server.js +++ b/server.js @@ -17,8 +17,6 @@ along with this program. If not, see . ------------------------------------------------------------------------- */ -process.stdout.write('\u001b[2J\u001b[0;0H') // console.clear() - const startHTTPS = true const isRoot = process.getuid && process.getuid() === 0 @@ -90,6 +88,19 @@ function exit (reason) { } const app = express() + +app.use(function (req, res, next) { + if (req.secure) { + next() + } else { + logger.DebugLog(`HTTPS ${req.method} redirect to: ${'https://' + req.headers.host + req.url}`, 'https', 1) + if (req.method === 'POST') { + res.redirect(307, 'https://' + req.headers.host + req.url) + } else { + res.redirect('https://' + req.headers.host + req.url) + } + } +}) // https://github.com/expressjs/cors#configuration-options app.use(cors({ credentials: true,