Jan 31 2023 02:09 PM
Hi, I deployed avery basic nodejs to an app service, when I browse the url
https://sieracnodejasdemo.azurewebsites.net/
I always get "HTTP ERROR 404"
FDirst I was using
const port = process.env.PORT || 3000;
then I replaced it by
const port = 80
still getting the same 404 error. Here is the full code for the index.js
var http = require('http');
var server = http.createServer(function(request, res) {
res.writeHead(200, { "Content-Type": "text/plain" });
var url = request.url;
if (url === '/about') {
res.write(' Welcome to about us page');
res.end();
} else if (url === '/contact') {
res.write(' Welcome to contact us page');
res.end();
} else {
res.write('Hello World!');
res.end();
}
});
const port = 80 //process.env.PORT || 80;
console.log(port);
server.listen(port);
console.log("Server running at http://%d", port);