Skip to content

CORS: Incorrect Status Code For OPTIONS endpoint #36526

@data-miner00

Description

@data-miner00

Description

Hi maintainers,

At the Preflight requests section, I think there is an incorrect expectation when it mentions that if the preflight request is denied, it return a 200 OK status code without CORS headers.

If the preflight request is denied, the app returns a `200 OK` response but doesn't set the CORS headers. Therefore, the browser doesn't attempt the cross-origin request. For an example of a denied preflight request, see the [Test CORS](#testc6) section of this document.

It should be returning 204 No Content instead. I've provided a screenshot that calls the OPTIONS endpoint with invalid origin and highlighted the status code. Can you guys help to confirm this behavior?

Image

Additionally, here is my simple setup in case you need a quick repro.

Thank you!

Page URL

https://learn.microsoft.com/en-us/aspnet/core/security/cors?view=aspnetcore-10.0

Content source URL

https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/security/cors.md

Document ID

d3f332c4-4c60-039e-0e1e-bc6b11831f87

Platform Id

fa70aa3f-a2de-be8b-4255-e778a6edb8ff

Article author

@tdykstra

Metadata

  • ID: 59bca5db-1196-2a8b-a0d8-4e89b2382288
  • PlatformId: fa70aa3f-a2de-be8b-4255-e778a6edb8ff
  • Service: aspnet-core
  • Sub-service: security

Related Issues


Associated WorkItem - 550679

Metadata

Metadata

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions