I used the latest Slim framework to develop an API backend for my frontend website. All is well, except one.
I use the API backend to process an image before it goes back to the frontend:
<?php
declare(strict_types=1);
namespace App\Application\Actions\Book;
use Psr\Http\Message\ResponseInterface as Response;
class ImageAction extends BookAction {
/**
* {@inheritdoc}
*/
protected function action(): Response {
$id = $this->resolveArg('bookid');
....
imagecopyresized($nimg, $oimg, 0, 0, 0, 0, $nw, $nh, $w, $h);
imagedestroy($oimg);
//header('Content-type: image/png');
imagepng($nimg);
imagedestroy($nimg);
return $this->respondWithData($nimg);
}
}
In short, this action put some text on the original image and resize it and return the image.
The problem I have now is that this reponse seems not holding the CORS header - the CORS header is in other JSON-responses.
Thanks!