title: Nancy + .NET Core enable CORS not working
body: <p>I have the following request on the clientside:</p>
  
  <pre><code>$.get(getUrl)
  </code></pre>
  
  <p>I have tried the following on the backend:</p>
  
  <p><a href="https://stackoverflow.com/questions/15658627/is-it-possible-to-enable-cors-using-nancyfx">Is it possible to enable CORS using NancyFX?</a></p>
  
  <p>I have also tried these four approaches (separately, hence commented out):</p>
  
  <pre><code>        // protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
      // {
      //     pipelines.AfterRequest += ctx =&gt;
      //     {
      //         ctx.Response.Headers.Add("Access-Control-Allow-Origin", "*");
      //         ctx.Response.Headers.Add("Access-Control-Allow-Headers", "*");
      //         ctx.Response.Headers.Add("Access-Control-Allow-Methods", "*");
      //     };
      // }
  
      protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
      {
          pipelines.AfterRequest += (ctx) =&gt;
          {
              ctx.Response.Headers.Add("Access-Control-Allow-Origin", "*");
          };
      }
  
      protected override void RequestStartup(TinyIoCContainer container, IPipelines pipelines, NancyContext context)
      {
          base.RequestStartup(container, pipelines, context);
  
          // pipelines.AfterRequest.AddItemToEndOfPipeline((ctx) =&gt;
          // {
          //     ctx.Response.WithHeader("Access-Control-Allow-Origin", "*")
          //         .WithHeader("Access-Control-Allow-Methods", "*")
          //         .WithHeader("Access-Control-Allow-Headers", "*");        
          // });
  
          // pipelines.AfterRequest += (ctx) =&gt;
          // {
          //     ctx.Response.Headers.Add("Access-Control-Allow-Origin", "*");
          //     ctx.Response.Headers.Add("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
          // };
  </code></pre>
  
  <p>I have even tried for my module something like:</p>
  
  <pre><code>After += (Context) =&gt;
  {
      Context.Response.Headers.Add("Access-Control-Allow-Origin", "*");
      Context.Response.Headers.Add("Access-Control-Allow-Methods", "PUT, GET, POST, DELETE, OPTIONS");
      Context.Response.Headers.Add("Access-Control-Allow-Headers", "Content-Type, x-requested-with, Authorization, Accept, Origin");
  };
  </code></pre>
  
  <p>All yield the same:</p>
  
  <pre><code>XMLHttpRequest cannot load http://localhost:5000/registration/signup. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:5001' is therefore not allowed access. The response had HTTP status code 401.
  </code></pre>
  
  <p>The 401 is because I am not passing in a custom header that is expected. I am just trying to work around the CORS issue first</p>