Hi folks
Thanks to @texnixe I was able to route the pattern apitest
to /home.json
, which is a simple JSON representation of my home site. The routing is as follows:
[
'pattern' => 'apitest',
'action' => function () {
return page('home')->render([], 'json');
}
],
The routing itself work, but the HTTP Content-Type of the response is set to text/html
instead of application/json
. I also tried to manually add the header with Header::contentType('application/json', 'UTF-8', true);
and header('Content-type: application/json');
but with no luck.
If I access the JSON representation without route at /home.json
, the Content-Type of the response is correctly set to application/json
.
Any ideas? Or maybe a bug?
Best,
Stefan