Adding the following to wp-settings.php fixed the problem, although I am not convinced that is is a good solution.
$_SERVER[‘REQUEST_URI’] = preg_replace(“/#respond$/”,”,$_SERVER[‘REQUEST_URI’]\);
Using a wildcard to remove all trailing #anchors is probably not a good idea as it would just hide potential future unrelated issues instead of showing up as 404 in the logs.