[Q] How to add custom header? #679
-
Hi, I am using RR2 and Laravel 8 with PHP 8.
How to configure RR to expose the custom header. Thank you. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Hi @francsiswanto! You should not use header() function for header setting - Middleware will be great for this. Something like that: namespace App\Http\Middleware;
class AppendStartedAtHeaderMiddleware
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
/** @var \Illuminate\Http\Response $response */
$response = $next($request);
$response->header('PHP-Start', date("Y-m-d H:i:s", LARAVEL_START));
return $response;
}
}
And put
|
Beta Was this translation helpful? Give feedback.
-
Thank you @tarampampam, I will try it tomorrow. |
Beta Was this translation helpful? Give feedback.
Hi @francsiswanto!
You should not use header() function for header setting - Middleware will be great for this. Something like that: