【发布时间】:2014-12-07 07:03:00
【问题描述】:
你能解释一下如何为我的服务器创建子域(明确没有 Express)吗?
为什么如果我执行以下操作,请求不会显示子域?
http = require("http");
server = http.createServer(function(req, res) {
console.log(req.url); //should prints "/" (because a subdomain should be considered like a new website)
console.log(req.headers.host); //should prints "sub.localhost"
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end("Ok");
}).listen(80);
现在,如果我导航到 http://sub.localhost/ chrome 显示“此网页不可用”并且从 node.js 控制台不打印任何内容,为什么?
是否有特定的程序来设置子域以便可以从节点访问?
【问题讨论】:
标签: javascript node.js http localhost subdomain