nelmio / NelmioCorsBundle

Adds CORS (Cross-Origin Resource Sharing) headers support in your Symfony application
https://symfony.com/bundles/NelmioCorsBundle/
MIT License
1.89k stars 108 forks source link

Hanging OPTIONS request in Safari #94

Closed chrisandchris closed 1 year ago

chrisandchris commented 6 years ago

When using Safari 10 on OS X (not the newest version, I can get more details tomorrow), the OPTIONS request may/will get stuck (hang, load forever), when the return state is not 204, but 200.

See this question on Stackoverflow: https://stackoverflow.com/questions/40339485/cors-options-request-successful-but-hangs-in-safari

This bundle returns 200 OK for the preflight, as tested here: https://github.com/nelmio/NelmioCorsBundle/blob/master/Tests/CorsListenerTest.php#L72

We actually ran into an issue with this. I don't see a possibility to change the response status within configuration (or by not actually using an event listener to override an event listener).

RFC 7231 (https://tools.ietf.org/html/rfc7231#section-4.3.7) states that the response might contain data, but when not is required to have Content-Length: 0 header. As far as I know, Symfony will set the appropriate content length header when there is no body.

In my opinion, the preflight may answer 204, which is a valid response given the fact that is does only contain header, but no actual content.

Seldaek commented 1 year ago

I'm assuming this problem was fixed on the client so closing here. I'd rather not change from 200 to 204 as this may in itself cause other problems with shitty clients or break someone's expectation.