I have a web project that I deployed on Railway, but I’m facing an issue when trying to display a .ejs page. When I click on it, I get the error:
“404 NOT FOUND - Nginx/1.24.0”
I don’t know where the problem is.
The website works 100% fine locally, but this issue happens after deployment.
Is there a solution?
nodeServer/index.js
app.set('view engine', 'ejs');
app.set('views', path.join(__dirname, '../views'));
app.get('/ejs-page', (req, res) => {
sql = 'SELECT * FROM upvote ORDER BY id DESC';
con.query(sql, function(error,data){
if (error)
{
console.error("error fetching data:",error);
}
res.render('script', {title:'Mhaaaa application', action:'add', sampleData: data});
res.render('script', { action:'add', sampleData: data});
});
});
views/script.ejs
index.html
<div class ="button-container">
<button onclick="window.location.href='/ejs-page';" class="button">
# ***This button redirects me to an EJS page when I click it.***
<span class="text">vote</span>
</button>