Tuesday, 4 April 2017

Force http:// to https:// in a sails.js App

I try to force my Sails.js WebApp from http:// to https:// and use this express middleware in my sail.js app:

In Express it would look like this:

app.use(forceDomain({
  hostname: 'www.example.com',
  port: 4000,
  protocol: 'https'
}));

I tried to use it in my config/http.js file in my sails.js app:

middleware: {

        forceDomain: function (req, res, next) {
            forceDomain({
                hostname: 'www.myurl.com',
                port: 4000,
                protocol: 'https'
            });
            next();
        },

        order: [
            'forceDomain',
          ...
}

I don't understand exactly how to use this "app.use()" thing in sails.js. It is here explained, but I didn't really understand. What I now have doesn't work. How can I fix this?



via PomeGranate

No comments:

Post a Comment