title: Axios CORS issue with Github oauth Not getting access token
body: <p>I have created 2 routes on my React-Redux app. I have added github applications settings with homepage and callback URL already.</p>
  
  <p>1.
  When you hit this route : <a href="https://reduxapp.herokuapp.com/signin" rel="noreferrer">https://reduxapp.herokuapp.com/signin</a>
  You click on Github login button, ==> <strong>githubGeturi</strong></p>
  
  <p>2.
  Github redirects back with a code <a href="https://reduxapp.herokuapp.com/auth/callback?code=9536286a59228e7784a1" rel="noreferrer">https://reduxapp.herokuapp.com/auth/callback?code=9536286a59228e7784a1</a>
  and <strong>githubSendCode</strong>('9536286a59228e7784a1') action is triggered</p>
  
  <p>You can see in network call OPTIONS call goes through, but POST call never happens. and you get a console error:</p>
  
  <pre><code>XMLHttpRequest cannot load https://github.com/login/oauth/access_token?client_id=32b70bf671e04762b26c&amp;…_secret=123456789123456789123456789&amp;code=9536286a59228e7784a1. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://reduxapp.herokuapp.com' is therefore not allowed access.
  </code></pre>
  
  <p><strong>Below is my action functions:</strong></p>
  
  <pre><code>const CLIENT_ID = '32b70bf671e04762b26c';
  const CLIENT_SECRET = '123456789123456789123456789';
  const ROOT_URL = window.location.origin;
  const REDIRECT_URL = `${ROOT_URL}/auth/callback`;
  const AUTHORIZE_URL = 'https://github.com/login/oauth/authorize';
  const ACCESS_TOKEN_URL = 'https://github.com/login/oauth/access_token';
  const STATE = _.random(10000);
  
  export function githubGeturi() {
    const GITHUB_URL = `${AUTHORIZE_URL}?client_id=${CLIENT_ID}&amp;scope=user,public_repo&amp;redirect_uri=${REDIRECT_URL}`;
  
    return (dispatch) =&gt; dispatch(signinUrl(GITHUB_URL));
  }
  
  export function githubSendCode(code) {
    const GITHUB_URL = `${ACCESS_TOKEN_URL}?client_id=${CLIENT_ID}&amp;client_secret=${CLIENT_SECRET}&amp;code=${code}`;
  
    axios.defaults.headers.post['Access-Control-Allow-Origin'] = '*';
    const axiosPost = axios.post(
      GITHUB_URL,
      {
      headers: {
        'Content-Type': 'application/x-www-form-urlencoded',
        'Accept': 'text/json'
      }
    });
  
    return (dispatch) =&gt; {
      dispatch(signinRequest());
      return axiosPost
        .then(
          success =&gt; dispatch(signinSuccess(success)),
          error =&gt; dispatch(signinError(error))
        );
    };
  }
  </code></pre>
  
  <p>========
  The only possible way I found is make POST call with server.
  You can view the entire solution here: <a href="https://github.com/steelx/ReduxWeatherApp/commit/6215634ca543a4760ea96397fe31b61f22184d91" rel="noreferrer">https://github.com/steelx/ReduxWeatherApp/commit/6215634ca543a4760ea96397fe31b61f22184d91</a></p>