gpt4 book ai didi

angularjs - Heroku Node.js 应用程序可以在本地运行,但在部署时无法运行

转载 作者:太空宇宙 更新时间:2023-11-03 22:54:00 24 4
gpt4 key购买 nike

我有一个运行良好的 MEAN Stack Heroku 应用程序。但后来我添加了一个新功能:

app.get('/userCreated/:id', function(req, res) {

if (req.cookies.userCreated == req.params.id) {
res.send(true);
}
else {
res.send(false);
}

});

现在我在加载应用程序时收到 503(服务不可用)错误。有人知道为什么会这样吗?

我正在使用 Angular 和 $http.get() 来访问此 Express.js 函数...

编辑:这是我的客户端 Angular 代码,它正在调用服务器:

var deferred = $q.defer();
function thisUserCreated(id) {
$http.get('/userCreated/' + id).success(function(data) {
deferred.resolve(data);
// returns boolean indicating whether the current user has the proper cookie
// saying this user created the given group
});
return deferred.promise;
};

最佳答案

嗯,其实我已经明白了。结果我没有在 package.json 中列出所有依赖项。

这里的教训:安装 Node 包时始终使用 --save

否则你会过得很糟糕。

关于angularjs - Heroku Node.js 应用程序可以在本地运行,但在部署时无法运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30207580/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com