How to set Heroku Port for NodeJS Express App?

so I’m trying to host my website on Heroku and set up everything to get my app up and running. Whenever I try to submit the form I get undefined errors. Undefined Errors Console Errors I’ve set it up to use the port like shown in the documenation: When starting the app locally with heroku local web I get Typerror: Failed to Fetch and the undefined results but when I go into my .env file and add a port=8081 it works perfectly fine. Good result When I open it with heroku open I still have that undefined problem. I don’t

Optional chaining operator gives SyntaxError when building my application to Heroku but works on my machine

I am using the optional chaining operator in my application, for instance: (checks if optionalField exists, then do something with it) The above code works perfectly on my machine but it gives me an error when I try to build this code on Heroku. Here is what the logs say: Does anyone know why is that? I suspect I should compile the code first using Babel and then deploy to Heroku? Is it even related to Babel? Answer Does anyone know why is that? Locally you’re using a recent version of Node.js that supports the optional chaining operator. Apparently Heroku