【发布时间】:2022-11-09 00:51:40
【问题描述】:
我在 Heorku 上部署了一个节点 appp。前端的节点应用程序使用 vanila js 和 ejs 模板来呈现 html 元素和 firebase 作为它的数据库。在开发中,我在本地主机上测试了一切,一切都很好,并且更快地呈现 html 元素,但是一旦部署在 Heroku 上,它就永远呈现我的 html元素。
我认为firestore是响应缓慢的原因。因此,当服务器启动时,我从 firestore 中提取所需的数据并将其存储在一个数组中。像这样 :
var allnewsarr =[];
function getNews(){
console.log('running')
fs.collection('news').orderBy("timestap",'desc').get().then((snaps)=>{
snaps.forEach((fillers)=>{
allnewsarr.push(fillers)
});
found = true;
console.log(allnewsarr.length, "are the articles")
// res.send(left[0].data())
})
.catch((error)=>{
repeat()
console.log(error.message);
})
}
server.listen(port,()=>{
getNews()// data is extracted only when the server starts
console.log(`The new logs ${port}`)}
);
【问题讨论】:
-
您是否在后端运行生产构建?
标签: node.js firebase heroku deployment