NancyFx / Nancy

Lightweight, low-ceremony, framework for building HTTP based services on .Net and Mono
http://nancyfx.org
MIT License
7.15k stars 1.46k forks source link

Why no CORS headers on Negotiate.WithStatusCode(non-success code)? #2958

Open mjgabriel opened 5 years ago

mjgabriel commented 5 years ago

Hi Nancy Version: 1.4.4 .NET Framework: 4.7.1

Just curious why CORS headers aren't included when I use something like Negotiate.WithStatusCode(HttpStatusCode.NotFound?

If using content negotiation, are you responsible for outputting everything that may be needed?

Negotiate.WithModel(model) includes the CORS headers without any additional code.

I know this isn't the format requested for issues. Just looking to be pointed any documentation I may have missed or misunderstood.

Thanks

mjgabriel commented 5 years ago

Found the following though:

Example 1 return Negotiate.WithStatusCode(HttpStatusCode.NotFound)

Returns no CORS headers when no model.

Example 2

return Negotiate
    .WithModel("Your request is bad. :(")
    .WithStatusCode(HttpStatusCode.BadRequest)

Returns CORS headers with model.

Example 3

return Negotiate.WithStatusCode(HttpStatusCode.NoContent)

Returns CORS headers (no .WithModel)