redirect all http request actions to https

http://stackoverflow.com/questions/2068418/whats-the-difference-between-a-302-and-a-307-redirect
This commit is contained in:
Radian 2016-07-16 15:25:31 +08:00 committed by GitHub
parent f0d9198223
commit d28b746d90
1 changed files with 1 additions and 1 deletions

View File

@ -131,7 +131,7 @@ var https = require('spdy');
function redirectHttp() { function redirectHttp() {
http.createServer(LEX.createAcmeResponder(lex, function redirectHttps(req, res) { http.createServer(LEX.createAcmeResponder(lex, function redirectHttps(req, res) {
res.setHeader('Location', 'https://' + req.headers.host + req.url); res.setHeader('Location', 'https://' + req.headers.host + req.url);
res.statusCode = 302; res.statusCode = 302; // use 307 if you want to redirect requests with POST, DELETE or PUT action.
res.end('<!-- Hello Developer Person! Please use HTTPS instead -->'); res.end('<!-- Hello Developer Person! Please use HTTPS instead -->');
})).listen(80); })).listen(80);
} }