I am trying to host my website, written with ExpressJS, using namecheap's cPanel, along with cloudflare, but can't seem to figure out how to deploy it. There isn't an option for a Node.js application so I resorted to using my cPanel's terminal to host it. Here's my basic ExpressJS code that I used for testing:
const express = require('express')
const https = require("https")
const fs = require("fs")
const app = express()
const cert = fs.readFileSync("./cert.crt")
const ca = fs.readFileSync("./ca.ca-bundle")
const key = fs.readFileSync("./private.key")
let options = {
cert: cert,
ca: ca,
key: key
}
let server = https.createServer(options, app)
app.get('/test', (req, res) => {
res.send('Hello World!')
})
server.listen(8080, 'shared ip', () => { console.log("Hosting!") });
Whenever I go to mydomain.com the index.html file gets served like normal, but when I go to mydomain.com/test I get a 404 not found. When looking at the GET request my site seems to be getting my server's IP with port 443 instead of 8080. Then when I go to mydomain.com:8080/test I get ERR_SSL_PROTOCOL_ERROR. I'm not totally sure how to fix this.