I've got a pretty large endpoint, and every fifth time or so I get the following error:
<b>Fatal error</b>: Uncaught yii\web\HeadersAlreadySentException: Headers already sent in /home/forge/**.**.**/vendor/yiisoft/yii2/web/Response.php on line 437. in /home/forge/**.**.**/vendor/yiisoft/yii2/web/Response.php:373
The error is displayed after the whole json output.
Because the frontend is on a different domain than the Craft instance, I set the following headers in element-api.php:
Craft::$app->getResponse()->getHeaders()->set('Access-Control-Allow-Origin', '*');
Description
I've got a pretty large endpoint, and every fifth time or so I get the following error:
<b>Fatal error</b>: Uncaught yii\web\HeadersAlreadySentException: Headers already sent in /home/forge/**.**.**/vendor/yiisoft/yii2/web/Response.php on line 437. in /home/forge/**.**.**/vendor/yiisoft/yii2/web/Response.php:373
The error is displayed after the whole json output.
Because the frontend is on a different domain than the Craft instance, I set the following headers in element-api.php:
Craft::$app->getResponse()->getHeaders()->set('Access-Control-Allow-Origin', '*');
Additional info