ember.js에서 오류 액세스 제어가-원점-허용하고 나에게이 오류 던지고있다 : 내 서버 측에서내가 ember.js을 사용하고
XMLHttpRequest cannot load http://127.0.0.1:20000/accounts/0 . Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin ' http://localhost:4200 ' is therefore not allowed access.
을, 나는을 인쇄하는 코드에 놓여있다 GET, POST 및 PUT 호출에 대한 로그. 아무것도 인쇄하지 않습니다. 따라서 클라이언트 측에서 서버에 요청하지 않았다고 생각합니다. ('http://127.0.0.1:20000/accounts/0'액세스는 수동으로 GET 메소드에서 로그를 수동으로 호출합니다.)
서버 측은 Access-Control-Allow-Origin을 반환하도록 이미 코딩되어 있으며 다른 방법에도 사용할 수 있습니다.
내 문제는 무엇인가요?
그리고 바로 레코드에 대한, 자바 서버 측은 다음과 같습니다
responseBuilder.header("Access-Control-Allow-Origin", "http://localhost:4200");
responseBuilder.header("Access-Control-Allow-Headers", "origin, content-type, accept, authorization, auth-token");
responseBuilder.header("Access-Control-Allow-Credentials", "true");
responseBuilder.header("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT");
responseBuilder.allow("OPTIONS");
및 설정/environment.js 내 ember.js에서
나는이 :ENV['contentSecurityPolicy'] = {
'default-src': "*"
};
프리 플라이트는 'OPTIONS'요청을 의미합니다. – CBroe
또한 OPTION 요청 허용 –
포트가 일치합니까? http : // localhost : 4200이 다른 도메인이므로 다른 포트 = http : //127.0.0.1:20000 – Shilly