title: Deploying Ionic2 on Heroku
body: <p>I am trying to deploy my ionic2 app on Heroku. I looked at these sites:</p>
  
  <ul>
  <li><a href="http://blog.ionic.io/one-mean-ionic-2-todo-app-on-heroku-part-1/" rel="nofollow noreferrer">http://blog.ionic.io/one-mean-ionic-2-todo-app-on-heroku-part-1/</a></li>
  <li><a href="https://www.joshmorony.com/building-a-review-app-with-ionic-2-mongodb-node/" rel="nofollow noreferrer">https://www.joshmorony.com/building-a-review-app-with-ionic-2-mongodb-node/</a></li>
  <li><a href="https://devdactic.com/deploying-ionic-to-heroku/" rel="nofollow noreferrer">https://devdactic.com/deploying-ionic-to-heroku/</a></li>
  </ul>
  
  <p>and created a <code>server.js</code> file:</p>
  
  <pre><code>var express  = require('express');
  var app      = express();                               // create our app w/ express
  var morgan = require('morgan');             // log requests to the console (express4)
  var bodyParser = require('body-parser');    // pull information from HTML POST (express4)
  var cors = require('cors');
  
  app.use(morgan('dev'));                                         // log every request to the console
  app.use(bodyParser.urlencoded({'extended':'true'}));            // parse application/x-www-form-urlencoded
  app.use(bodyParser.json());                                     // parse application/json
  app.use(bodyParser.json({ type: 'application/vnd.api+json' })); // parse application/vnd.api+json as json
  // app.use(methodOverride());
  app.use(cors());
  
  app.use(function(req, res, next) {
    res.header("Access-Control-Allow-Origin", "*");
    res.header('Access-Control-Allow-Methods', 'DELETE, PUT');
    res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
    next();
  });
  
  app.use(express.static('www'));
  app.set('port', process.env.PORT || 5000);
  app.listen(app.get('port'), function () {
    console.log('Express server listening on port ' + app.get('port'));
  });
  </code></pre>
  
  <p>Since I have no models and no DB at this time, I excluded mongo and mongoose.</p>
  
  <p>The server runs fine when I run it on my local machine via <code>npm start</code> but when I run it on heroku, I get:</p>
  
  <pre><code>Cannot GET /
  </code></pre>
  
  <p>on the page. Heroku Logs shows:</p>
  
  <pre><code>2017-01-04T19:56:59.385666+00:00 heroku[web.1]: State changed from starting to up
  2017-01-04T19:57:00.546815+00:00 heroku[router]: at=info method=GET path="/" host=hrmghp-companion.herokuapp.com request_id=4c010120-3dce-4f99-b31c-99dc0883f314 fwd="108.44.230.178" dyno=web.1 connect=1ms service=49ms status=404 bytes=364
  2017-01-04T19:57:00.549928+00:00 app[web.1]: GET / 404 19.924 ms - 13
  </code></pre>
  
  <p>Am I missing something in my <code>server.js</code> file?</p>
  
  <p><strong>Edit:</strong>
  I found the issue. I had <code>www/</code> in my <code>.gitignore</code> file. I assumed that it would rebuild the app when deploying to heroku? Is this not how it works?</p>