vendredi 27 mars 2020

force encoding to work on request made for laravel api by web browser

I am maintaning an API that have some requests made by a front-end app. When I call it from postman, all work well, including its encoding. The response is:

{ "message": "Esse nome de usuário está disponível" }

However, when I make it from browser, I receive:

{"message":"Esse nome de usu\u00e1rio est\u00e1 dispon\u00edvel"}

I already made this tutorial, that creates an middleware forcing the encoding, and on my project I set it like this, unlike the code it sugests:

$request->headers->set('Accept', 'application/json; charset=UTF-8');
$request->headers->set('Charset', 'utf-8');

In postman, I saw that these headers were not setted in the response of the request.

Also, I already tried to set in my controller response:

return response()->json([
                'message' => __('auth.nickname_available'), 
            ], 200, ['Content-Type' => 'application/json;charset=UTF-8', 'Charset' => 'utf-8']);

I followed this tip. But neither worked.

How can I can make this work well?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/33RsdPW
via IFTTT

Aucun commentaire:

Enregistrer un commentaire