title: Force http:// to https:// in a sails.js App
body: <p>I try to force my Sails.js WebApp which is hosted on heroku(no nginx installed) from http:// to https:// and use this <a href="https://github.com/thenativeweb/forcedomain" rel="nofollow noreferrer">express middleware</a> in my sail.js app:</p>
  
  <p>In Express it would look like this:</p>
  
  <pre><code>app.use(forceDomain({
    hostname: 'www.example.com',
    port: 4000,
    protocol: 'https'
  }));
  </code></pre>
  
  <p>I tried to use it in my config/http.js file in my sails.js app:</p>
  
  <pre><code>middleware: {
  
          forceDomain: function (req, res, next) {
              forceDomain({
                  hostname: 'www.myurl.com',
                  port: 4000,
                  protocol: 'https'
              });
              next();
          },
  
          order: [
              'forceDomain',
            ...
  }
  </code></pre>
  
  <p>I don't understand exactly how to use this "app.use()" thing in sails.js. 
  It is <a href="https://imfly.gitbooks.io/sailsjs-docs-gitbook/content/en/concepts/Middleware/Middleware.html" rel="nofollow noreferrer">here explained</a>, but I didn't really understand. What I now have doesn't work(no errors, but also no redirecting). How can I fix this?</p>
  
  <p>Installed <a href="https://www.npmjs.com/package/sails-hook-httpsredirect" rel="nofollow noreferrer">this module</a> - doesn't work either.</p>