I have an application, which use SF2, FOS-RestBundle, MySQL, AngularJS. Symfony is being used just to provide REST API for my frontend application written in Angular. Everything works great when I have debug mode enabled and my API urls are like:
"HOST/app_dev.php/api/users"
But when I switch to production environment and change my urls to:
"HOST/api/users"
I keep getting such an error:
{"error":{"code":500,"message":"Internal Server Error"}}
This is my FOSRest configuration (and sensio framework):
sensio_framework_extra:
view: { annotations: false }
router: { annotations: true }
request: { converters: true }
fos_rest:
routing_loader:
default_format: json
include_format: true
param_fetcher_listener: force
body_listener: true
allowed_methods_listener: true
view:
view_response_listener: 'force'
formats:
json: true
format_listener:
rules:
- { path: '^/api', priorities: ['json', 'xml'], fallback_format: null, prefer_extension: true }
- { path: '^/', priorities: [ 'text/html', '*/*'], fallback_format: null, prefer_extension: true }
access_denied_listener:
json: true
I know, that error is triggered somewhere in FOSRestBundle, but I have a 'breakpoint' in ExceptionController. It does not even go there.
Screenshot of error and headers
Appreciate any help.
When I figured out how to get to server logs in my hosting I found a following error:
Your data could not be encoded because it contains invalid UTF8 characters." at app/endor/jms/serializer/src/JMS/Serializer/JsonSerializationVisitor.php line 36
And solution is here ("SET NAMES UTF8" did the trick):