意思是.js - 登录后重定向用户 - 在本地工作,但在部署时不起作用

MEAN.js - Redirect user after signin - Works locally but not when deployed

本文关键字:工作 部署 不起作用 登录 重定向 用户 意思是 js      更新时间:2023-09-26

我试图在注册后重定向用户,但无论出于何种原因,它在本地工作而不是在部署时

这是函数,部署时$window.location.href = '/settings/picture';不起作用

$scope.signup = function (isValid) {
  $scope.error = null;
  if (!isValid) {
    $scope.$broadcast('show-errors-check-validity', 'userForm');
    return false;
  }
  $http.post('/api/auth/signup', $scope.credentials).success(function (response) {
    // If successful we assign the response to the global user model
    $scope.authentication.user = response;
    // And redirect to avatar selection screen
    $window.location.href = '/settings/picture'; 

  }).error(function (response) {
    $scope.error = response.message;
  });
};

您可以尝试在post('/api/auth/signup')路由中使用res.render('/settings/picture', {title: whatever title}),而不是在控制器中使用$window.location.href

或者尝试提供完整的地址,例如 $window.location.href = "http://domain.com/settings/pictures.html"