...and my goal is to have Express.JS listen on that domain without specifying a port number.
It's important to note that you always need to listen on a specific port. HTTP typically uses port 80 (e.g., when visiting http://example.com
) while HTTPS uses port 443. These are the standard ports that web servers use for listening to requests.
If your ExpressJS code is running on a server with the IP address associated with the domain name, you can still follow the usual ExpressJS method for handling HTTP requests. Here's an adapted version of their "Hello World" example, adjusted to listen on port 80 and include semicolons:
const express = require('express');
const app = express();
const port = 80; // <===
app.get('/', (req, res) => res.send('Hello World!'));
app.listen(port, () => console.log(`Example app listening on port ${port}!`));