2017-10-05 175 views
1

我正在使用nodejs和angularjs 1.6.4。一切工作在本地主机很好,但是当我通过Github将我的代码推到数字海洋液滴时,饼干不起作用。我保存到Cookie的所有内容都不会显示在Cookie存储中。为什么会发生?Cookie在本地主机上运行良好,但无法在VPS上运行

UPDATE 当我去到VPS登录页面显示一条警告:"This page includes a password or credit card input in a non-secure context. A warning has been added to the URL bar"

下面是相关代码:

$scope.login = function() { 

     UserService.login($scope.user).then(function (result) { 
     if (result.data.success) { 
      $rootScope.userLogin = result.data.data.name; 

      //------------------ 
      var day = new Date(); 
      day.setDate(day.getDay() + 30); 

      var options = { 
      domain: "localhost", 
      httpOnly: true, 
      expires: day 
      }; 
      // cookie does not work, nothing in Cookie Storage 
      // but it works perfectly on localhost 
      $cookies.put('token', result.data.data.token, options); 
      $cookies.put('name', result.data.data.name, options); 
      // the session storage work greatly 
      $sessionStorage.user = 'heheeheh'; 
      flash.success = result.data.message; 
      $state.go('home'); 
     } else { 
      flash.error = result.data.message; 
     } 
     }); 
    } 

UPDATE:

我创造了另一个VPS在亚马逊EC2,但它仍然无法正常工作。

+0

任何错误,或者在控制台显示的警告? – nicktendo

+0

另请发布相关代码。 – nicktendo

回答

1

我发现,刚刚从localhost改变domain选项服务器的IP

相关问题