반응형
클라이언트 소스(브라우저)
1
2
3
4
5
6
7
8
9 |
$.ajax({
url : "192.168.48.123/api/client" ,
type : "POST" ,
cache : false ,
dataType: "json" ,
success: function (data) {
console.log(data);
},
}); |
오류메세지
XMLHttpRequest cannot load http://192.168.48.123/api/client. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '192.168.48.456' is therefore not allowed access.
XMLHttpRequest cannot load http://192.168.48.123/api/client. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '192.168.48.456' is therefore not allowed access.
해결방법(서버 Node.js 소스 수정)
1
2
3
4
5
6 |
response.type( 'application/json' ); response.header( "Access-Control-Allow-Origin" , "*" ) response.json(200, {
code : code,
result : result }); |
참고사이트
'프로그래밍 > Node.js' 카테고리의 다른 글
Node.js - URL별로 다른 HTML 페이지 제공하기 (0) | 2015.01.02 |
---|---|
Node.js - Location 속성을 이용한 페이지 강제 이동 시키기 (0) | 2015.01.02 |
Node.js - 포트2개를 사용한 이미지와 음악파일 서버 만들기 (0) | 2015.01.02 |
Node.js - File System 모듈을 이용한 HTML 페이지 제공 (0) | 2015.01.02 |
Node.js - mysql 데이터베이스 연동 방법 (0) | 2015.01.01 |
Node.js - EventEmitter 객체를 활용한 이벤트 생성 및 처리 (0) | 2014.12.31 |
Node.js - File System 모듈 사용하기 (0) | 2014.12.31 |
Node.js - connect.multipart() will be removed in connect 3.0 해결법 (0) | 2014.12.27 |