Skip to content

Instantly share code, notes, and snippets.

@nethoncho
Created August 28, 2016 19:27
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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();
};
@greguz
Copy link

greguz commented Feb 27, 2017

I've created a simple hook to achieve this.

@nethoncho
Copy link
Author

Your hook works nicely. Thanks

@mikermcneil
Copy link

@CrashedBboy
Copy link

Thanks for sharing!

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