클라이언트 소스(브라우저)
$.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 소스 수정)
response.type('application/json');
response.header("Access-Control-Allow-Origin" , "*")
response.json(200, {
code : code,
result : result
});
참고사이트
"JavaScript / Node.JS" 분류의 다른 글
| [node.js] cluster를 이용한 멀티코어(multi-core) 사용 (0) | 2013/10/22 |
| [node.js] traceback (0) | 2013/10/22 |
| [node.js] log4js PatternLayout 사용하기 (0) | 2013/10/21 |
| [node.js] Strict mode (0) | 2013/10/21 |