I have a large piece of text in my DB stored and can successfully pull it from my DB
, dd()
it and log::debug()
the content with no issues. The text can be seen here: https://pastebin.com/KQNYW623
The problem comes when I try to return a JSON response of the text. On a clean Lumen 5.7 install in the api.php
route file I have this route:
$router->get('/', function () use ($router) {
return json_encode("*insert large content here*"); //this is where the big text goes, I won't paste it fully here but it's here in my code as a string
});
If I access this route, I get a blank page. Absolutely nothing appears in either my screen, Postman or curl
. There's no errors in the error logs, nothing. Just blank.
If I place anything else that is much smaller than the large text (like hello world) I have no problem outputting the response. Can someone please shed some light on what the root cause of this issue is? Is there a character limit for responses in Lumen/Laravel?
--- UPDATE ---
So if I do echo response()->json($string)
(where $string
) is a variable that holds the long text) I can see the string has been encoded into JSON and the response headers have been added and all this is outputted on screen. However, doing return response()->json($string)
still continues to return a blank response.
Would anyone know why the return
is not sending back the data from the response()
?
Fixed the problem: a CORS middleware class that I picked up from here: enter link description here
Responses with a Content-Length
> 6K were being manipulated to have a length of 0 but still return a 200 response. Thanks for the help and advice to all.