For some reasons I send JSON response from my helper/library instead of controller using below code:
response()->json(
[
"status" => false,
"message" => "This product is out of stock",
],
200
)->send();
exit;
my problem is no middleware header if that response sent. How to attach header to all response()->json()->send();exit; function?
Below us my response header of default controller ):

Above response has all header from all middleware and below is my header response from response()->json()->send();exit;:
above not showing headers from the middleware.
I know I can send the header manually by add ->header('X-Header-One', 'Header Value') like code below:
response()->json(
[
'status' => false,
'message' => 'This voucher is not for selected products',
]
)->header('X-Header-One', 'Header Value')->send();
exit;
But I already have so many that responses, and I dont want to try to WETing my code.
