title: Access to fetch at _ from origin _ blocked by CORS policy: Response to preflight request doesnt pass access control check: doesnt have HTTP ok status
body: <p>I'm trying to make authorized requests to LinkedIn's API after using OAuth2.0 to sign in users. I keep getting errors regarding the CORS policy and need help in sending the correct headers so that I no longer get these errors.</p>
  
  <p>I've tried including a couple different 'Access-Control-Request' headers but I keep getting the same error. I'm pretty sure it has something to do with the 'Authorization' header I'm sending to the API, but this header is required from the documentation to receive the correct information.</p>
  
  <p><a href="https://docs.microsoft.com/en-us/linkedin/shared/authentication/authorization-code-flow?context=linkedin/context#step-1-configure-your-application" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/linkedin/shared/authentication/authorization-code-flow?context=linkedin/context#step-1-configure-your-application</a></p>
  
  <p>The code I'm using to make this call is shown below...</p>
  
  <pre><code>async function getProfileData(accessToken, expiresIn) {
    const requestUrl = `https://api.linkedin.com/v2/me`;
    const response = await fetch(requestUrl, {
      method: 'GET',
      headers: {
        'Host': 'api.linkedin.com',
        'Connection': 'Keep-Alive',
        'Authorization': `Bearer ${accessToken}`,
        'Origin': REDIRECT_URI,
        'Access-Control-Request-Method': 'GET',
        'Access-Control-Request-Headers': 'Content-Type, Authorization'
      }
    });
    return response;
  }
  </code></pre>
  
  <p>The accessToken, in this case, comes from a previous network call using an authorization code from a previous step. Everything before this is working and I'm getting a response with what I assume to be a valid access token. </p>
  
  <p>Previously, I was getting an error saying that my access token wasn't valid even though I followed the documentation step-by-step to retrieve it. I'm not sure if this is the same issue or not, but I can't see a reason why I would have an invalid token (the token wasn't expired and I never rejected the permissions on sign-in).</p>
  
  <p>The response I'm expecting to get back from the call is the basic profile data from the user that is signed in but instead, I get this:</p>
  
  <pre><code>OPTIONS https://api.linkedin.com/v2/me 401
  getProfileData @ app.js:74
  (anonymous) @ app.js:50
  
  Access to fetch at 'https://api.linkedin.com/v2/me' from origin 'https://simple-linkedin-login2.netlify.com' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.
  </code></pre>