node.js로 작성된 나머지 api 응용 프로그램이 있습니다. & Express가 동일한 서버의 포트 9001에서 실행되는 포트 3000 및 angularjs 응용 프로그램에서 실행 중입니다. angularjs 응용 프로그램에서 rst api를 호출하면 cors 문제가 발생합니다. 나머지 API는 응용 프로그램에서 나머지 api 응용 프로그램 서버 (익스프레스) 및 Angulars js 응용 프로그램이 다른 포트에서 실행 중일 때 Cors 문제
, 나는 "고르"모듈var cors = require('cors');
app.use(cors());
사용했다 그러나 오류
다음 날주고있다Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:3000/api/user/login. This can be fixed by moving the resource to the same domain or enabling CORS
을 따를 요청 헤더와 응답 헤더입니다 응답 헤더
,210소스보기
요청 헤더
Accept application/json, text/plain,/
Accept-Encoding gzip, deflate
Accept-Language en-US,en;q=0.5
Authorization null
Content-Length 47
Content-Type application/json;charset=utf-8
Host localhost:3000
Origin http://localhost:9001
Referer http://localhost:9001/
User-Agent Mozilla/5.0 (Windows NT 6.2; WOW64; rv:35.0) Gecko/20100101 Firefox/35.0
감사
미안 해요 내 실수, 나는 여기에 제대로 입력하지 않았습니다. 내 코드에서 그것은 app.use (cors()); – Abhimanyu