title: Javascript - Fetch to API returning 'from origin 'null' has been blocked by CORS policy'
body: <p>I am using the following javascript to perform an API call and do different things depending on the response:</p>
  
  <pre><code>const passwordApiUrl = 'https://www.test.net/youin/api/password/'
  
  // When RESET button clicked
  function onReset() {
      const urlParams = new URLSearchParams(window.location.search);
      const resetCode = urlParams.get('resetcode');
      const password = $('#txtPassword').val();
  
      const apiPath = passwordApiUrl + resetCode;
      alert(apiPath);
      sendPostRequest(apiPath, password)
          .then(response =&gt; {
            console.log(response.status);
              if (response.status !== 200) {
                  // Error
                  alert('error');
              } else {
                  // Fine
                  alert('pass');
              }
          })
  }
  
  async function sendPostRequest(url, data) {
      return await fetch(url, {
          method: 'POST',
          headers: {
              'Content-Type': 'application/json'
          },
          body: JSON.stringify(data)
      });
  }
  </code></pre>
  
  <p>This is the full error message in the console - ccess to fetch at '<a href="https://www.test.net/youin/api/password/b0dBNnFlVVQ0TWorZklTbnBreGdkYnZLMlF2MTJ0R3g2VEd3RlZRa2Jia3lLeWNRVkpGTW5oVkw1K3hqR01xa3dUZWtrWFVzQmhLVEFSU280SFlaS2F4OTdLalg2Z1p1dFg5YU9YN3huTzA9" rel="nofollow noreferrer">https://www.test.net/youin/api/password/b0dBNnFlVVQ0TWorZklTbnBreGdkYnZLMlF2MTJ0R3g2VEd3RlZRa2Jia3lLeWNRVkpGTW5oVkw1K3hqR01xa3dUZWtrWFVzQmhLVEFSU280SFlaS2F4OTdLalg2Z1p1dFg5YU9YN3huTzA9</a>' from origin 'null' has been blocked by CORS policy: Request header field content-type is not allowed by Access-Control-Allow-Headers in preflight response.</p>
  
  <p>Any advice on how to fix?</p>