0

i keep getting method not allowed error when trying to deploy to Heroku.

The logs do not have much info:

Server is started !

 2018-02-18T01:55:03.853131+00:00 heroku[web.1]: State changed from 
 starting to up
 2018-02-18T01:59:08.949257+00:00 heroku[router]: at=info method=GET 
 path="/" host=tyler-dev.herokuapp.com request_id=d19953f5-ab72-4374-
 8bb3-1c391b72912b fwd="74.135.3.158" dyno=web.1 connect=0ms service=41ms 
 status=404 bytes=380 protocol=https




2018-02-18T01:59:08.949562+00:00 app[web.1]: Error: ENOENT: no such file 
 or directory, stat '/Users/tyler/WebDev/portfolio/main/views/index.html'
 2018-02-18T01:59:09.910620+00:00 heroku[router]: at=info method=GET 
 path="/favicon.ico" host=tyler-dev.herokuapp.com request_id=04a7bd40-
 ea40-4806-ba01-b4dd318d41eb fwd="74.135.3.158" dyno=web.1 connect=0ms 
 service=4ms status=404 bytes=394 protocol=https

The file that says that is missing is not and is in that location. When running the app locally, everything works fine. here's my node/express app set up.

app.get('/', function(req, res){
    res.sendFile(path.join(_dirname + '/views/index.html'));
});

app.set('port', (process.env.PORT || 5000));

app.listen(app.get('port'), function(){
    console.log("Server is started!")
});

Has anybody had anything like this happen to them?

Am I setting something up wrong with Heroku?

Any help would be great, Thank you!

Tyler Mckee
  • 1
  • 1
  • 2

1 Answers1

0

This is an older post, but it could be that you need path.resolve rather than path.join.

Serving static files from an express/node.js application

Gerik
  • 698
  • 3
  • 11