레일 백엔드 앱을 쓰고 있습니다. 나는 별도로 일하는 프론트 엔드 개발자에게 휴식 API를 제공하고있다.XMLHttpRequest 아니요 'Access-Control-Allow-Origin'헤더가 없습니다. SimpleHttpServer에서
#todo remove this once ui is integrated into the app. following allows requests from other domains (disble CORS).
config.action_dispatch.default_headers.merge!({
'Access-Control-Allow-Origin' => '*',
'Access-Control-Request-Method' => '*'
});
내가이 떨어져 실행하고 간단한 HTML 페이지에 링크를 사용하여 API를 테스트하려고를 :되는 시간을 내 application.rb에 다음을 추가하여 크로스 원산지 자원 공유를 활성화 그래서 python SimplHttpServer. 페이지가 http : // localhost : 8000/TestPage.html에서 제공되고 있습니다.
링크 중 하나를 테스트하면 (현재 jquery를 사용하여 jquery를 백엔드로 전송하여 현재 로컬에서 실행 중입니다. http : // localhost : 3000) 다음 오류가 발생합니다.
GET http://localhost:3000/campaigns/my_campaigns?user_email=swapna%40urbancoding.net&user_token=SNa2kPqkm5ENsZMx7yEi
XMLHttpRequest cannot load http://localhost:3000/campaigns/my_campaigns?user_email=xyz.xyz.com&user_token=xyz. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost : 8000' is therefore not allowed access. The response had HTTP status code 500.
무슨 일입니까? 이 문제를 어떻게 해결할 수 있습니까?