伙计们,在cPanel中连接云mongodb是可能的。现在我有了服务器错误502,因为我理解它的mongoDb错误,我不太擅长这个东西,部署项目。
我的代码:
const PORT = --PORT;
const hostname = --hostname;
const DB_URL = 'mongodb+srv://user:password@cluster0.4ie8h.mongodb.net/bootcamp?retryWrites=true&w=majority';
async function start(){
try{
mongoose.connect(DB_URL, {
useUnifiedTopology: true,
useNewUrlParser: true,
autoIndex: true,
})
app.listen(PORT, hostname, () => { console.log('Server started on port ' + PORT)});
}catch(e){
console.log(e);
}
}开始();
发布于 2022-03-13 15:57:16
你的代码似乎绝对正确。请记住,"502“通常是”不良网关“错误,这意味着您的web服务很可能没有正确地将请求转发到应用程序的正确端口。确保在您的.htaccess文件中有正确的重写规则。您的网站托管提供商应该能够帮助这一点。
https://stackoverflow.com/questions/71428327
复制相似问题