Application Error on Heroku after deploying

After deploying an app on Heroku, I’m getting an application error. Then I checked the logs which showed the following error:

2020-06-07T05:47:43.079647+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/" host=damp-thicket-34530.herokuapp.com request_id=cf32b3b0-0291-42d7-924e-aa36cafb03e1 fwd="203.190.9.142" dyno=web.1 connect=0ms service=30000ms status=503 bytes=0 protocol=https

I’m not sure what’s this error is about. Here is my app.js file:

require('dotenv').config();
var createError = require('http-errors');
var express = require('express');
var path = require('path');
var cookieParser = require('cookie-parser');
var logger = require('morgan');
const connectDB = require('./config/db');

var usersRouter = require('./routes/api/users');
var moviesRouter = require('./routes/api/movies');

var app = express();

// connect database
connectDB();

app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));

app.use('/api/users', usersRouter);
app.use('/api/movies', moviesRouter);

if (process.env.NODE_ENV === 'production') {
  app.use(express.static('client/build'));
  app.get('*', (req, res) => {
    res.sendFile(path.resolve('client', 'build', 'index.html'));
  });
}

const PORT = process.env.PORT || 5000;

app.listen(PORT, () => console.log(`Server started on port ${PORT}`));

I will highly appreciate any suggestions. Thanks in advance.

Go to Source
Author: sam13