title: JS Fetch API not working with ASP.NET Core 2 Controllers with Authorize attribute
body: <p>I'm having the following code on the client side:</p>
  
  <pre><code>fetch("/music/index", { headers: { "Content-Type": "application/json" } })
      .then(response =&gt; {
          if (!response.ok) {
              throw response;
          }
          return response.json();
      })
      .then(json =&gt; {
          console.log("Done! It's all good");
      })
      .catch(response =&gt; console.log(response));
  </code></pre>
  
  <p>Unfortunately this doesn't even reach the <code>MusicController</code> (server-side), which looks as follows (simplified to illustrate the point):</p>
  
  <pre><code>[Authorize]
  public class MusicController : Controller {
      public async Task&lt;IActionResult&gt; Index() {        
          IEnumerable&lt;Song&gt; songs = await _songsRepository.GetAll();
          return Json(songs);
      }
  }
  </code></pre>
  
  <p>From what I see in the developer console I'm being redirected to <code>/Account/Login?returnUrl...</code></p>
  
  <p>Meanwhile, using the jquery api, everything seems to work fine:</p>
  
  <pre><code>$.get("/music/index")
      .done(json =&gt; console.log("Done! It's all good"))
      .fail(error =&gt; console.log(error));
  </code></pre>
  
  <p>I have a suspicion that I'm not setting my headers right? Not sure couldn't find anything on the net. Also this (or rather very similar) code used to work in previous (non-Core) versions of ASP.NET.</p>