【问题标题】:Nodejs Session issue with www and non-wwwwww和非www的Nodejs会话问题
【发布时间】:2015-10-17 09:42:00
【问题描述】:

我有以下情况

(1) 如果我访问https://example.com 如果进入登录页面。

(2) 如果我访问https://www.example.com,则相同 它进入登录页面

现在我从https://example.com 登录,它重定向到仪表板页面,这很好。 当我再次访问https://example.com 时,它会将我重定向到仪表板页面。

现在的问题,当我访问 https//www.example.com 时,它会重定向到登录页面。

这意味着我可以登录两个会话

1) https://example.com 2)https://www.example.com 在同一个浏览器上。 ?

请问这个怎么处理。

我也在使用 http 重定向。

http.createServer(function (req, res) {
    res.writeHead(301, { "Location": "https://www." + req.headers['host'] + req.url });
    res.end();
}).listen(80);
var secureServer = https.createServer(sslOptions,app).listen(443, function(err,result){

   console.log("Express server listening on port : 443");
    console.log("Mode : " + app.get('mode'));
});

有什么建议吗?

谢谢

【问题讨论】:

    标签: javascript node.js http session https


    【解决方案1】:

    只是不要在多个主机名上托管您的网站。选择一个规范并重定向(使用301 HTTP 响应)来自另一个的所有请求到它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-12-18
      • 1970-01-01
      • 1970-01-01
      • 2011-12-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多