Closed shorif2000 closed 2 years ago
The response object you pass to the error handler does not contain the headers. Try something like this instead:
"error" => function ($response, $arguments) {
$data = [
'details' => [
'message' => 'Unauthorized',
],
'message' => $arguments["message"]
];
$response->getBody()->write(json_encode($data, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
return $response
->withHeader('Access-Control-Allow-Origin', $_ENV['ALLOWED_DOMAINS'])
->withHeader(
'Access-Control-Allow-Headers',
'X-Requested-With, Content-Type, Accept, Origin, Authorization'
)
->withHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, PATCH, OPTIONS')
->withHeader('Content-Type', 'application/json');
}
set the following
trigger an expired request but none of the headers get set so I had to change it to