I'm using Laravel in version 5.4 (PHP 5.6) to develop an API.
Recently, when the API was published in Umbler (Linux), when trying to access endpoints that return strings with special characters (more specifically ù, ã, í) and / or UUIDs the following exception is thrown
The function of the controller being called is the following:
public function index(Request $request)
{
$response = $this->service->get($request->all());
return response()->json([
'message' => 'Success',
'data' => $response['paginated']->getCollection(),
'next_page' => $response['paginated']->nextPageUrl(),
'prev_page' => $response['paginated']->previousPageUrl(),
'current_page' => $response['paginated']->currentPage(),
'page_count' => $response['paginated']->lastPage(),
]);
}
I tried to use laravel accessors in entities to return the data in the following ways:
public function getIdAttribute($value) {
return utf8_encode(Uuid::import($value)->string);
}
public function getValorAttribute($value) {
return utf8_encode($value);
}
But the problem persists.
I noticed that by uploading Builtin Web Server ( php artisan serve
) to a Windows server the error does not occur, but when using Apache or Nginx, it happens again.
Obs : On this same Windows server, when you add% with the apache settings, the problem has been remedied, but in Ubuntu not.
Has anyone ever had this kind of problem and knows how to solve it?