0
내 Angular 2 응용 프로그램이 노드를 사용하여 빌드하고 다른 포트 3003에서 실행중인 Express 프로젝트 인 8100 포트 및 API 프로젝트에서 실행됩니다. API 프로젝트는 나머지 API 프로젝트가 아닙니다.로컬 서버의 Angular 2 Cross Doamin Call이 작동하지 않습니다.
Rest Client 또는 Postman에서 API 중 하나를 호출하려고하면 응답이 나타납니다.
노드에서 API를 호출하려고해도 잘 작동합니다.
Angular 2 프로젝트에서 API 호출을하는 동안 404 오류가 표시됩니다.
각도 2 코드 -
getApplications() {
let headers = new Headers();
headers.append('Content-Type', 'application/json');
headers.append('cache-control', 'no-cache');
headers.append('Access-Control-Allow-Origin', '*');
return this.http.post('http://localhost:3003/applications/list', {}, {})
.map(res => res.json());
}
NodeJS 작업 요청 -
var request = require("request");
var options = {
method: 'POST',
url: 'http://localhost:3003/application/list',
headers:
{
'cache-control': 'no-cache',
'content-type': 'application/json'
}
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
우편 배달부 요청 -
,363,210
너무 감사합니다! 나는 그것을 놓친 방법을 믿지 않습니다. – Kanchan