title: Laravel: Encode JSON responses in UTF-8
body: <p>I want to encode the JSON responses of my API to UTF-8, but every time I make a response I don't want to do this:</p>
  
  <pre><code>return response()-&gt;json($res,200,['Content-type'=&gt;'application/json;charset=utf-8'],JSON_UNESCAPED_UNICODE);
  </code></pre>
  
  <p>So I thought about making a middleware for all API routes which <code>handle(...)</code> function would be this:</p>
  
  <pre><code>public function handle($request, Closure $next) {
      $response = $next($request);
      $response-&gt;header('Content-type','application/json; charset=utf-8');
      return $next($request);
  }
  </code></pre>
  
  <p>The problem is that it doesn't work, the <code>Content-type</code> header of my responses is still <code>application/json</code> and not <code>application/json; charset=utf-8</code>; maybe because the <code>json(...)</code> function already sets a <code>Content-type</code> header and I cannot override it.</p>
  
  <p>How should I do?</p>
  
  <p>Thank you for your help.</p>