title: Google OAuth2: Redirect has been blocked by CORS policy: Request requires preflight, which is disallowed to follow cross-origin redirect
body: <p>Trying to implement Google OAuth2 and using <a href="https://github.com/google/google-api-nodejs-client#authorizing-and-authenticating" rel="nofollow noreferrer">https://github.com/google/google-api-nodejs-client#authorizing-and-authenticating</a> as reference.  When redirecting user to consent page like this</p>
  
  <pre><code>var url = oauth2Client.generateAuthUrl({
      access_type: 'offline',
      scope: some_scope
      });
   res.redirect(url);
  </code></pre>
  
  <p>I get this error in browser console (links edited):</p>
  
  <blockquote>
    <p>XMLHttpRequest cannot load localhost:8080/myPageName. Redirect from localhost:8080/myPageName to accounts.google.com/o/oauth2/auth?access_type=... has been blocked by CORS policy: Request requires preflight, which is disallowed to follow cross-origin redirect.</p>
  </blockquote>
  
  <p>The strange thing is that I am getting this error only when executing the flow from GUI (user presses the button; angular2 front-end). When I put localhost:8080/myPageName directly into the browser address bar everything works fine (get consent form and then tokens).</p>
  
  <p>Any help is appreciated. Thank you.</p>