Custom routes return 404 error but correct content with HEAD request

Probably related to this issue: How to use a custom router?, with response::json() not working.