Skip to content

Instantly share code, notes, and snippets.

@nethoncho
Created August 28, 2016 19:27
Show Gist options
  • Save nethoncho/cefe66d7ef2ea103d3db7aed6f426728 to your computer and use it in GitHub Desktop.
Save nethoncho/cefe66d7ef2ea103d3db7aed6f426728 to your computer and use it in GitHub Desktop.
/*
* config/bootstrap.js
* Example of how to redirect all http request to https
* See http://jsbot.io/node/http-and-https-handle-with-sailsjs
*
*/
module.exports.bootstrap = function(cb) {
var express = require("express")
var app = express();
app.get('*', function(req,res) {
if(req.isSocket)
return res.redirect('wss://' + req.headers.host + req.url);
return res.redirect('https://' + req.headers.host + req.url);
}).listen(80);
cb();
};
@CrashedBboy
Copy link

Thanks for sharing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment