Closed mario-fehr closed 2 years ago
@mfehr94 the exception is only thrown when you are not requesting the page with .json
. When using the headless bundle you need to make sure that you request the json using /your-url.json
. Without it requires a .html.twig
as you are then requesting a html response. So this behavoiur is expected.
If you use javascript server side (Next.js, Nuxt, ...) rendered implementation all request to /your-url
(without .json) should be handled by that serve and so never hit sulu itself. This is something you need to make sure in your VHost or server routing. Else if sulu provide the html where a client side application is started to communicate over with the headless bundle create one headless.html.twig
which is used by every template which just starts your client javascript.
@alexander-schranz thank you for the explanation. My mistake was I did not change the view
property in the template xml files. So there are two ways of doing this. Use <view>base</view>
or <view>pages/headless</view>
if you want to use templates/pages/headless.html.twig
Actual Behavior
If now twig file exist for the template the exception get thrown. If the twig file exist for the template everthing is just fine.
Expected Behavior
No need to create the twig template files if the template should be used as headless.
Steps to Reproduce
Here is a link to the demo repo with the bug.