Problem with deploying my URL shortener to heroku

Problem with deploying my URL shortener to heroku
0.0 0


Hi guys I am working on the URL shortener project. My code works perfectly when on local host. However once I deploy it to heroku, it stops working and returns this log:

2017-06-01T09:09:35.775535+00:00 heroku[web.1]: Starting process with command `node app.js`
2017-06-01T09:09:38.581345+00:00 app[web.1]: Working on port 3000
2017-06-01T09:09:38.608859+00:00 app[web.1]: Db.prototype.authenticate method will no longer be available in the next major release 3.x as MongoDB 3.6 will only allow auth against users in the admin db and will no longer allow multiple credentials on a socket. Please authenticate using MongoClient.connect with auth credentials.
2017-06-01T09:09:39.556990+00:00 heroku[web.1]: State changed from starting to up
2017-06-01T09:17:19.853949+00:00 heroku[router]: at=info method=GET path="/" request_id=88e143ee-3594-4cd0-b785-f5cf6ca59995 fwd="" dyno=web.1 connect=1ms service=20ms status=200 bytes=1095 protocol=https
2017-06-01T09:17:20.251753+00:00 heroku[router]: at=info method=GET path="/css/style.css" request_id=fba4b790-b7de-4fa9-b188-eadeb9c029a3 fwd="" dyno=web.1 connect=2ms service=8ms status=304 bytes=236 protocol=https
2017-06-01T09:17:20.508190+00:00 heroku[router]: at=info method=GET path="/js/app.js" request_id=390ac557-a702-4ad8-a55c-035ecfa65148 fwd="" dyno=web.1 connect=1ms service=2ms status=304 bytes=236 protocol=https
2017-06-01T09:17:20.964371+00:00 app[web.1]: events.js:163
2017-06-01T09:17:20.964380+00:00 app[web.1]:       throw er; // Unhandled 'error' event
2017-06-01T09:17:20.964381+00:00 app[web.1]:       ^
2017-06-01T09:17:20.964382+00:00 app[web.1]: 
2017-06-01T09:17:20.964382+00:00 app[web.1]: TypeError: Cannot read property 'originalUrl' of null
2017-06-01T09:17:20.964383+00:00 app[web.1]:     at /app/app.js:59:12
2017-06-01T09:17:20.964386+00:00 app[web.1]:     at model.Query.<anonymous> (/app/node_modules/mongoose/lib/model.js:3748:16)
2017-06-01T09:17:20.964387+00:00 app[web.1]:     at /app/node_modules/kareem/index.js:277:21
2017-06-01T09:17:20.964387+00:00 app[web.1]:     at /app/node_modules/kareem/index.js:131:16
2017-06-01T09:17:20.964388+00:00 app[web.1]:     at _combinedTickCallback (internal/process/next_tick.js:73:7)
2017-06-01T09:17:20.964389+00:00 app[web.1]:     at process._tickCallback (internal/process/next_tick.js:104:9)
2017-06-01T09:17:21.039631+00:00 heroku[web.1]: State changed from up to crashed
2017-06-01T09:17:20.971001+00:00 heroku[router]: at=error code=H13 desc="Connection closed without response" method=GET path="/favicon.ico" request_id=9ceaec06-24eb-4989-badb-61c39dd74884 fwd="" dyno=web.1 connect=1ms service=27ms status=503 bytes=0 protocol=https
2017-06-01T09:17:21.028977+00:00 heroku[web.1]: Process exited with status 1

My github repository is here:

Any idea what’s wrong? Appreciate it a lot!!!


Your error is at this line in your code You need to check if your query found any results because if it didn’t then the data parameter will be null.