2017-10-05 137 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

相關問題