I have simple Node Express app with one route that I need to deploy on Heroku - When I run command - git push heroku master, it is build successfully. After generating the link - I am trying to access it, but all I am getting is Aplication Error.
When checking the console by heroku logs --tail, this is the output:
And I checked my dashboard and everything looks fine
This is the first time using Heroku so I am not sure what it can cause, from my research it might often be missing script in package.json, but I added that
{
"name": "myApp",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"scripts": {
"start": "nodemon server.js"
},
"dependencies": {
"cors": "^2.8.5",
"dotenv": "^10.0.0",
"express": "^4.17.1",
"serve": "^12.0.1",
"stripe": "^8.178.0"
}
}
And this is the Server.js (the main config of Express)
const express = require('express');
const cors = require('cors');
const dotenv = require('dotenv');
dotenv.config();
const app = express();
app.use(express.json());
app.use(
express.urlencoded({
extended: true,
})
);
app.use(cors());
const configureRoutes = require('./routes');
configureRoutes(app);
const port = process.env.PORT || 9090;
const server = app.listen(port, (error) => {
if (error) {
console.log('Error running Express');
}
console.log('Server is running on port', server.address().port);
});
Am I missing something? Why can't I access the link if everything seems running fine? (locally there's no prob of course - so it has to be something during build)