node.js app returns 'Cannot GET /' once deployed on CPanel

Jan 15, 2021
7
2
3
USA
cPanel Access Level
Website Owner
the app displays and behaves perfectly on localhost but does not display at all once deployed on CPanel. I have deployed it on CPanel and run the command npm install from the GUI and I have run it also from the terminal using 'npm install -g npm-check-updates' followed by 'ncu -u' I have tried to deploy the app the same way once more in case I made a mistake and get the same result. I don't understand why it does not seem to find 'app.get("/"'

app.js

var app = express();
var mysql = require("mysql"); // allow access to sql
var bodyParser = require("body-parser");
const path = require("path");
const VIEWS = path.join(__dirname, "views");
app.use(express.static("scripts"));
app.use(express.static("images"));
let index = 0;
var session = require("express-session");
var globalGallery = [];
let filter = false;
var lastSearchItem = "";
//var MySQLStore = require('express-mysql-session')(session);
app.use(
bodyParser.urlencoded({
extended: true,
})
);
app.set("view engine", "pug");

const db = mysql.createConnection({
host: "-------",
user: "------",
password: "--------",
database: "--------",
port: 3306,
});

db.connect((err) => {
if (err) {
throw err;
} else {
console.log("db connected!");
}
});
app.get("/", function (req, res) {
let sql = "select * FROM photo ORDER BY photoId DESC; ";
let query = db.query(sql, (err, gallery) => {
if (err) throw err;
globalGallery = gallery;
filter = false;
res.render("index", {
gallery: globalGallery,
});
});
});
index.pug

extends layout

block content
.maincontent
form(method="post" action="/filterphotos")
input.search(name="search", type="text", Placeholder="type 'ir' for example...")
button.searchbutton(type="submit") Search
.grid-container
each photo in gallery
- var text
- text = photo.photoPlace? photo.photoPlace : text
- text = photo.photoCountry? text+" "+photo.photoCountry : text
- text = photo.photoComments? text+" "+photo.photoComments : text

a.div.tooltip(href='/displayphoto/'+photo.photoId)


img.photothumbnail(src="Index of /images/"+photo.photoThumbnail, alt=photo.photoThumbnail)
if text.length > 1
span.tooltiptext #{text}
package.json

{
"name": "isabellebidou.photos",
"version": "1.0.0",
"description": "photo website",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "photoapp"
},
"author": "",
"license": "ISC",
"dependencies": {
"body-parser": "^1.19.0",
"constantinople": "^4.0.1",
"express": "^4.17.1",
"express-session": "^1.17.1",
"jade": "^1.11.0",
"mysql": "^2.18.1",
"path": "^0.12.7",
"pug": "^3.0.0"
}
}
 
Last edited by a moderator:
  • Like
Reactions: archiebryann

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
17,470
2,843
363
cPanel Access Level
Root Administrator
@melvinanorman99 - I'm sorry I missed this thread! If you have root access to the system I'd recommend submitting a ticket to our team so we can check the system for you. Your profile on the forums indicates that you only have cPanel access, and if that is the case you would need to reach out to your hosting provider or datacenter for additional help with that as you may not have access to the logs necessary to troubleshoot the issue.