Express app deployed on cPanel not rendering Pug templates

12 Views Asked by At

I have a NodeJS project using MongoDB and .pug templates. I deployed it on a VPS server with WHM and cPanel. After uploading the files through cPanel, I started the NodeJS app from the WHM terminal, and it successfully runs on port 80. However, when I visit my domain (domain.com), it shows an "index of" page instead of rendering my .pug templates.

Here's a simplified version of my app.js:

const express = require('express');
const app = express();
const port = 80;

// View engine setup
app.set('view engine', 'pug');
app.set('views', './views');

// Routes and other setup...

app.listen(port, () => {
    console.log(`Server running on port ${port}`);
});

When I manually created an index.html file with "Hello" in it, it displays correctly at domain.com. But my project's .pug files are not rendering.

What could be the issue here? How can I get my Express app to render the .pug templates when accessing domain.com?

0

There are 0 best solutions below