title: Aurelia Post with http-fetch-client producing an options request
body: <p>I'm creating a small forum where people in our company can put up adverts for goods or services they want to sell on the fly, using aurelia. I have a list of adverts page working fine, a details page for each advert working fine both using get requests from an api. However i can't seem to get the work the Post reqeust when someone wants to add a comment on an advert.</p>
  
  <pre><code>@inject(HttpClient)
  export class ApiData {
      constructor(httpClient) {
          httpClient.configure(config =&gt; {
              config
                  .withBaseUrl("MyUrl");
          });
          this.http = httpClient;
          //.configure(x =&gt; {x.withHeader('Content-Type', 'application/json');});
      }
  
      postAdvertComment(comment, id) {
          return this.http.fetch(`/adverts/${id}/comments`, {
              method: "post",
              body: json(comment),
              headers: {
                  'Accept': 'application/json'
              }
          });
      } 
  
      getAdverts() {
          return this.http.fetch("/adverts")
              .then(response =&gt; {
                  return this.adverts = response.json();
              });
      }
  
      getAdvert(id) {
          return this.http.fetch(`/adverts/${id}`)
              .then(response =&gt; {
                  return this.advert = response.json();
              });
      }
  }
  </code></pre>
  
  <p>Doing this project we've had some issue with CORS, all solved by adding in AllowCors tags in the api, including all methods etc.</p>
  
  <pre><code>&lt;add key="CorsAllowedOrigins" value="*" /&gt;
  &lt;add key="CorsAllowedHeaders" value="" /&gt;
  &lt;add key="CorsAllowedMethods" value="*" /&gt;
  </code></pre>
  
  <p>However when i try and run the post, its running an options method and returns a 400 Bad request. 
  <a href="http://i.stack.imgur.com/dWg22.png" rel="nofollow">Here</a></p>
  
  <p>We also get the following CORS error:</p>
  
  <pre><code>Fetch API cannot load MyURL/api/adverts/2/comments. Response to preflight
  request doesn't pass access control check: No 'Access-Control-Allow-Origin'
  header is present on the requested resource. Origin 'http://localhost:49877' is 
  therefore not allowed access. The response had HTTP status code 400. If an 
  opaque response serves your needs, set the request's mode to 'no-cors' to fetch 
  the resource with CORS disabled.
  </code></pre>
  
  <p>I don't know if it's a problem with our c# api or with how I'm trying to post from aurelia, but we have tried sending requests from postman and it works fine, tried sending post request within the same app using jquery and it works fine, and all the get requests work fine, but for some reason this post is causing all sorts of problems.</p>