Answer the question
In order to leave comments, you need to log in
Why does the web server (node.js + nginx) return undeclared content when requesting a page?
I came across a very strange situation in which, in the process of requesting a page, the server, among other things, returns a bunch of garbage (various requests to third-party services), which greatly slows down page loading.
var http = require('http');
http.createServer(function(req,res){
var path = req.url.replace(/\/?(?:\?.*)?$/, '').toLowerCase();
switch (path) {
case '':
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Homepage');
break;
case '/about':
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('О нас');
break;
default:
res.writeHead(404, {'Content-Type': 'text/plain'});
res.end('Не найдено');
}
}).listen(8181);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question