I want to push and commit my MERN stack application. The deployment in the terminal goes well but when I launch the app via the Heroku URL the app does not load properly. Google Developer Tools console does not help, so i used
heroku logs --tail
and found two errors, shown below!
2022-05-18T01:21:18.212028+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=qode-so.herokuapp.com request_id=ad010e60-74da-411c-b25f-794a9cc31df7 fwd="98.52.109.235" dyno= connect= service= status=503 bytes= protocol=https
2022-05-18T01:21:20.923308+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=qode-so.herokuapp.com request_id=2e87a149-2982-4582-8e42-6fdf136cef7c fwd="98.52.109.235" dyno= connect= service= status=503 bytes= protocol=https
I tried adding a Heroku Procfile but it just threw another with a different error code so i just removed it to prevent the struggle of figuring out another error, I checked my server.js and everything looks fine. Here is the server.js
code.
const express = require('express');
const connectDB = require('./config/db');
const path = require('path');
const app = express();
app.use(express.json());
connectDB();
// route
app.use('/api/users', require('./routes/api/users'));
app.use('/api/auth', require('./routes/api/auth'));
app.use('/api/profile', require('./routes/api/profile'));
app.use('/api/posts', require('./routes/api/posts'));
app.use('/api/tags', require('./routes/api/tags'));
app.use('/api/notify', require('./routes/api/notifications'));
if (process.env.NODE_ENV === 'production') {
app.use(express.static('client/build'));
app.get('*', (req, res) => {
res.sendFile(path.resolve(__dirname, 'client', 'build', 'index.html'));
});
}
const PORT = process.env.PORT || 5000;
app.listen(PORT, () => console.log(`Server started on port ${PORT}`));
Has anyone encountered this before and could help? I tried to use the solutions already listed at H10-App Crashed Error And How To Solve Them.
Top comments (0)