File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -87,11 +87,14 @@ public static function render(\Throwable $error)
8787 try {
8888 $ app = Factory::getApplication ();
8989
90- // Flag if we are on cli
90+ // Flag if we are on cli or api
9191 $ isCli = $ app ->isClient ('cli ' );
92+ $ isAPI = $ app ->isClient ('api ' );
9293
9394 // If site is offline and it's a 404 error, just go to index (to see offline message, instead of 404)
94- if (!$ isCli && $ error ->getCode () == '404 ' && $ app ->get ('offline ' ) == 1 ) {
95+ if ($ isCli || $ isAPI ) {
96+ // Do nothing.
97+ } elseif ($ error ->getCode () == '404 ' && $ app ->get ('offline ' ) == 1 ) {
9598 $ app ->redirect ('index.php ' );
9699 }
97100
@@ -141,6 +144,11 @@ public static function render(\Throwable $error)
141144 }
142145
143146 if ($ isCli ) {
147+ echo $ data ;
148+ } elseif ($ isAPI ) {
149+ $ app ->setHeader ('Content-Type ' , $ app ->mimeType . '; charset= ' . $ app ->charSet );
150+ $ app ->sendHeaders ();
151+
144152 echo $ data ;
145153 } else {
146154 /** @var CMSApplication $app */
You can’t perform that action at this time.
0 commit comments