-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CORS Headers not added on Exception (500 error code) #62
Comments
+1 |
1 similar comment
+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 |
@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 throw new Reader\Exception('Unable to identify a reader for this file'); |
+1, annoying af |
Closing as duplicate of #124 |
The bundle does not add CORS headers on error (500) response, e.g. those generetaed by FOSRestBundle
The text was updated successfully, but these errors were encountered: