When trying to deploy my website on Heroku, I encountered the following error message:
Application error
An error occurred in the application and the page could not be served. As the application owner, I checked the logs for details as suggested by Heroku CLI using the command Heroku logs --tail
Upon checking the logs, there doesn't seem to be any major issues. The information displayed was:
2020-09-20T23:56:47.790226+00:00 app[web.1]:
2020-09-20T23:56:48.040459+00:00 app[web.1]: SERVER IS RUNNIG AT PORT 8000
2020-09-20T23:56:48.040768+00:00 app[web.1]: Server running at http://127.0.0.1:5500
2020-09-20T23:57:44.991177+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2020-09-20T23:57:45.017244+00:00 heroku[web.1]: Stopping process with SIGKILL
2020-09-20T23:57:45.087257+00:00 heroku[web.1]: Process exited with status 137
2020-09-20T23:57:45.132990+00:00 heroku[web.1]: State changed from starting to crashed
2020-09-21T02:05:44.125661+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=sheetsw.herokuapp.com request_id=b87a2aae-a1d1-44d4-9f4e-2d10421edec6 fwd="27.60.151.127" dyno= connect= service= status=503 bytes= protocol=https
2020-09-21T02:05:46.906817+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=sheetsw.herokuapp.com request_id=a46e447c-e111-4954-a6c6-a1e928013a82 fwd="27.60.151.127" dyno= connect= service= status=503 bytes= protocol=https
2020-09-21T02:06:05.637299+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=sheetsw.herokuapp.com request_id=d6aa7d9b-60eb-450c-8ceb-c063faad3917 fwd="27.60.151.127" dyno= connect= service= status=503 bytes= protocol=https
I am seeking guidance on what might be causing this issue and how I can resolve it. Any help would be appreciated.
This is a snippet from my server.js file:
const express = require("express");
const fs = require('fs');
const nodemailer = require('nodemailer');
const bodyParser = require('body-parser');
const hostname= '127.0.0.1';
const port= 5500;
const path = require('path');
const app = express();
app.get('/register.html',(req,res) => {
res.sendFile(__dirname + '/register.html')
})
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true}));
sending();
function sending(){
const transporter = nodemailer.createTransport({
service:'gmail',
auth:{
user:'<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1774787b7b727463797e6457707a767e7b3974787a">[email protected]</a>',
pass:'free_fire123'
}
});
function sendEmail(mail)
{
var mailOptions= {
from: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ea898586868f899e848399aa8d878b8386c4898587">[email protected]</a>',
to:mail.to,
subject: mail.subject,
html: mail.body
}
transporter.sendMail(mailOptions, function(err, info) {
if(err){
console.log(err+" "+mail.to)
}
else {
console.log("Email sent: "+info.response)
}
})
}
app.post('/register.html', (req,res)=> {
mail= {
to:req.body.to_address,
subject:"Sheets_Wrap - project details",
body:req.body.NAME + " ------------/////////////------------ "+ req.body.phone + " ------------/////////////------------ " + req.body.email_body + " ------------/////////////------------ " + req.body.code
}
sendEmail(mail)
res.redirect('/register.html')
})
app.listen(port, ()=> {
console.log('SERVER IS RUNNIG AT PORT 8000')
console.log(`Server runnung at http://localhost:${port}/register.html`);
})
}