我尝试在localhost上运行我的Angular 2应用程序和它的后端应用程序(node.js)并在浏览器的控制台中出错:
后端应用中没有错误:
我在后端应用程序中使用此代码以避免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可能是?)
我该如何解决这个问题?