无法使用节点服务器从angular2 http post请求中调用php文件


Cannot call the php file from angular2 http post request using node server

我有如下的rest调用。就像交叉定义域。我想调用在同一个项目文件夹中的php文件。但我得到404错误。我可以使用错误链接下载文件。这意味着我给出的链接是正确的。

return this._http
    .post('/app/php/reports.php', data.toString(), {headers: this.headers})
    .toPromise()
    .then(res => res.json().data)
    .catch(this.handleError);

报头定义如下。private headers = new headers ({'Content-Type': 'application/json'});

导入的文件列在下面

 import { Headers, Http, Response } from '@angular/http';
 import { Injectable } from '@angular/core';
 import { Observable } from 'rxjs/Observable';
 import 'rxjs/add/operator/map';
 import 'rxjs/add/operator/toPromise';

是否有任何依赖于npm server调用php文件。我已经用"sudo npm install php-embed"更新了节点服务器,我仍然面临这个问题。我希望这是一个问题与节点服务器调用。php文件。我可以使用get请求调用xml文件。这里我想把数据发布到php文件

Angular2使用lite-server,它的默认端口是3000。输入主机作为wamp/lamp服务器路径(php文件放置的位置)。例如:localhost、localhost:80或localhost:8080检查下面的代码。

return this._http
    .post('http://localhost/app/php/reports.php', data.toString(), {headers: this.headers})
    .toPromise()
    .then(res => res.json().data)
    .catch(this.handleError);