React + Redux + RoR을 사용하고 있습니다. 나는 사회적 로그인을해야한다. 클라이언트 측을 위해 나는 davezuko/react-redux-starter-kit을 사용하며 localhost : 3000에 있습니다. 내 서버 - localhost : 5000. 클라이언트에서 서버로의 모든 요청은 문제가 없습니다 (PUT, GET, POST). 나는 트위터 사용하여 로그인을 시도 할 때 (로컬 호스트, 서버에서의 일을 : 5000/인증/트위터 - 트위터에서 PARAMS와 DB에 새로운 사용자를 생성) 나는 오류가 : 클라이언트 측에Reux Redux <아니요 '요청한 리소스에 Access Control-Allow-Origin 헤더가 있습니다. Origin 'null'은 허용되지 않습니다. access>
Failed to load https://api.twitter.com/oauth/authenticate?oauth_token=xxxxx: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.
이 같은 전화를 :
export const requestTest = async() => {
return axios.get('http://localhost:5000/auth/twitter', {}).then(function (response) {
console.log('cors')
console.log(response)
return response.data
})
}};
는내가 그것을 어떻게 를 해결할 수 있습니까?
하나의 컴퓨터에서 개발하고 다른 컴퓨터에서 테스트합니다. 가장 쉬운 방법은 브라우저 확장을 무시하고 CORS를 사용하는 것입니다. 경고 : 나는 당신이 이것을 정기적으로 찾아보기 위해 켜 놓아야한다고 생각하지 않는다. https://chrome.google.com/webstore/detail/cors-toggle/jioikioepegflmdnbocfhgmpmopmjkim?hl=ko –
좋은 지적은 가능한 또 다른 해결책입니다. –