如标题所述,我的网站出现“无法加载资源:net :: ERR_CONNECTION_REFUSED”错误。
“ TypeError:无法获取”和“ Unchecked runtime.lastError:消息端口在收到响应之前已关闭”。在控制台日志中由于某种原因。
此外,在Heroku上的构建日志中,它也显示“ NPM_CONFIG_LOGLEVEL = error”。
据我了解,这种情况发生在端口未侦听任何内容时。但是我不确定情况如何或为什么。
我尝试使用process.env.NODE而不是env.PORT在端口之间进行切换(将端口从5000更改为3000等)。没有变化。
所有内容均基于此Pusher新闻Feed应用程序教程。这是我关于server.js类的一些代码(假设这是我所需要的全部)。
app.get('/live', (req, res) => {
const topic = 'ipo';
fetchNews(topic, 1)
.then(response => {
res.json(response.articles);
updateFeed(topic);
})
.catch(error => console.log(error));
});
app.set('port', process.env.PORT || 5000);
const server = app.listen(app.get('port'), () => {
console.log('Express running -> PORT ${server.address().port}');
});
此外,我的app.js代码的一小部分
componentDidMount() {
fetch('http://localhost:5000/live')
.then(response => response.json())
.then(articles => {
this.setState({
newsItems: [...this.state.newsItems, ...articles],
});
}).catch(error => console.log(error));
我不确定到底是怎么回事。
答案 0 :(得分:0)
问题出在Heroku不是您的本地主机时,您如何获取PartsListItem
呢?