From d4ea3ff68f5b476aab009672968d3d348782a367 Mon Sep 17 00:00:00 2001 From: Noah Loomans Date: Wed, 8 Mar 2017 11:07:42 +0100 Subject: Use 301 redirect instead of 302 --- bin/www | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/www b/bin/www index 1c08756..4c375d3 100755 --- a/bin/www +++ b/bin/www @@ -25,6 +25,11 @@ function setupHTTPS () { app.set('port', httpsPort) } +function redirectToHTTPS (req, res) { + res.writeHead(301, { 'Location': 'https://' + req.headers['host'] + req.url }) + res.end() +} + function setupHTTPSRedirect () { const httpPort = normalizePort(process.env.PORT || '3000') const httpServer = http.createServer(redirectToHTTPS) @@ -110,8 +115,3 @@ if (useHTTPS) { console.warn(`NOT USING HTTPS! Could not read ${fileLocations.privkey}`) setupHTTP() } - -function redirectToHTTPS (req, res) { - res.writeHead(302, { 'Location': 'https://' + req.headers['host'] + req.url }) - res.end() -} -- cgit v1.1