Closed martinopic closed 1 year ago
+1
+1
I have a curious case here. I have a POST endpoint that returns a 404 status. When the request payload is empty, the CORS header is correctly added. When it has any content ({'foo': 'bar'} for example) it's not added. Anyone has seen this?
I don't think CORS headers are not added to 500 response, we have an application that uses FOSRestBundle and we got CORS headers on 500 responses. The problem, I think, is with PHP fatal errors which are not exceptions e.g. memory exceeded but, unfortunately, also NPEs.
The only way I know of handling these errors is to register a custom function but as the script completely stop to execute when encountering a fatal error the function would be "outside symfony" and all error hadling, error rest response and cors headers should be done outside the framework inside this very single function. Not impossible but really annoying and clumsy.
Pretty much a PHP limit. Seems to be overcome in PHP version 7 (still haven't tried that): http://php.net/manual/en/language.errors.php7.php
Even in PHP7. not all errors are catchable unfortunately, although more are.
I'm seeing this happen (no Access-Control-Allow-Origin header present) on routes that through a NotFoundHttpException
or doctrine exceptions. Is this expected behaviour?
I got the same issue, I'm using Symfony 3.4 and Nelmio Cors 1.5.6. I think this is related to: https://github.com/nelmio/NelmioCorsBundle/issues/124 @Seldaek is this issue fixed in new Nelmio Cors version 2.0.1?
@st0at It is not, because I am finding this case on version 2.0.1. And it's not on a fatal error, just a regular exception thrown by the phpoffice/phpspreadsheet
library:
throw new Reader\Exception('Unable to identify a reader for this file');
+1, annoying af
Closing as duplicate of https://github.com/nelmio/NelmioCorsBundle/issues/124
The bundle does not add CORS headers on error (500) response, e.g. those generetaed by FOSRestBundle