title: set header in middleware
body: <p>I tried to set a header in a middleware to avoid Google bot for indexing something like a login page. And I actually made it work but came across this error which I cannot understand.</p>
  
  <pre><code>public function handle($request, Closure $next)
  {
  
      $next($request)-&gt;header('x-robots-tag', 'none', false);
  
      return $next($request);
  }
  </code></pre>
  
  <p>The code above won't add this header <code>x-robots-tag: none</code> while the below code does.</p>
  
  <pre><code> public function handle($request, Closure $next)
  {
      $response = $next($request);
  
      $response-&gt;header('x-robots-tag', 'none', false);
  
      return $response;
  }
  </code></pre>
  
  <p>Isn't it basically the same thing? The only difference is putting <code>$next($request)</code> in a variable or not. Why is this?</p>