I have a problem with my node app. I use express to server pages with my node app. But it looks like that the base function:
app.use(express.static('public'));
app.use(express.static('allure-report'));
app.get('/', (req, res) => {
//myHtmlCode is read my fs from index.html
//res.send(myHtmlCode);
//res.render('index', { html: myHtmlCode })
res.writeHead(200, {
'Content-Type': 'text/plain'
});
res.write(myHtmlCode);
});
In all this cases, node will server the index.html page that is inside the public folder. If I remove the index.html page from public folder, it will server the index.html from allure-report folder.
How I can tell node not to serve the index.html file and server the dynamic content in the "app.get('/', (req, res) => {" function? It do not work with send, render or write.
It looks like that node complete ignore the function or route "/" if the index.html file is available.
It looks like that
app.get('/', function(req, res) {
is never called.
app.use
andapp.get
calls. The order you write them in the code is the priority it get matched. – Ricky Mo