为什么NodeJS下载文件而不是保存Web

时间:2019-03-21 09:00:13

标签: node.js http web

我不确定Mac OS和Windows之间为什么会有区别。 问题是,在Windows环境中,Chrome / Edge下载的是NodeJS响应,而不仅仅是加载网页。每当我在Chrome / Edge上访问“ localhost:8081”时,就会一次又一次地发生。我想像MAC OS那样做,有人可以救我吗? Windows侧面响应 Windows

在MacOS上,它确实停留在浏览器窗口上。 对这个问题有什么想法吗? 忘记提及NodeJs版本,MACOS:v10.15.3,WINDOWS:v11.12.0 希望在这种情况下版本无关紧要。 :'( MacOS

谢谢!

var http = require('http'); 

http.createServer(function (request, response){

    response.writeHead(200, {'Content-Type': 'text/plain'});
    response.end('HelloWorld');

}).listen(8081);

console.log('server running at http://127.0.0.1:8081/');

0 个答案:

没有答案