Angular2,NodeJs:在localhost上运行时出现错误“net :: ERR_CONNECTION_REFUSED”

时间:2017-04-04 07:33:33

标签: node.js angular

我尝试在localhost上运行我的Angular 2应用程序和它的后端应用程序(node.js)并在浏览器的控制台中出错:

enter image description here

后端应用中没有错误:

enter image description here

我在后端应用程序中使用此代码以避免CORS错误:

app.use(function * (next) {
    this.response.set('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE');
    this.response.set('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept');
    this.response.set('Access-Control-Allow-Origin', '*');
    yield * next;
});

在我看来,问题与前端应用有关(zone.js可能是?)

我该如何解决这个问题?

更新:修复https后的相同错误 - > HTTP   enter image description here

0 个答案:

没有答案