TYPO3 Version: 9.5.4
Goal: I want to return a 404 error from an Extbase controller with the proper status code etc. that uses the configuration for 404 error handling I set up in the site configuration.
Check that 404 handling works: I setup a 404 error handling in the site configuration. This should show the content of a specific page. If I go to www.my-domain.local/asdfasdf I will get a 404 status code with the content of the page I specified
What did I try in Extbase:
# In the action
return GeneralUtility::makeInstance(ErrorController::class)->pageNotFoundAction(
$GLOBALS['TYPO3_REQUEST'],
'The requested page does not exist',
['code' => PageAccessFailureReasons::PAGE_NOT_FOUND]
);
Result:
Variant A (No error handling in site configuration): Exception with status code 404 > O.K
Variant B (Error handling to show content of page): Page renders with status 200, shows normal content of said page (header, footer etc.) > Not O.K
Question: How do I get Extbase to do the same thing as the normal pages?