Tuesday, 4 April 2017

Angular2, NodeJs: Got an error "net::ERR_CONNECTION_REFUSED" when run onthe localhost

I try to run my Angular 2 app and it's backend app (node.js) both on the localhost and get an error in browser's console:

enter image description here

There are no errors in the backend app:

enter image description here

I used this code in the backend app to avoid CORS error:

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;
});

It seems to me the problem is related to the frontend app (zone.js may be?)

How can I solve this problem?



via Zurab-D

No comments:

Post a Comment