def METHOD_NAME(response, request):
    """Return a JSON 404 error response."""
    config_key = "trailing_slash_redirect_enabled"
    redirect_enabled = request.registry.settings[config_key]
    trailing_slash_redirection_enabled = asbool(redirect_enabled)
    querystring = request.url[(request.url.rindex(request.path) + len(request.path)) :]
    errno = ERRORS.MISSING_RESOURCE
    error_msg = "The resource you are looking for could not be found."
    if not request.path.startswith(f"/{request.registry.route_prefix}"):
        errno = ERRORS.VERSION_NOT_AVAILABLE
        error_msg = "The requested API version is not available " "on this server."
    elif trailing_slash_redirection_enabled:
        redirect = None
        if request.path.endswith("/"):
            path = request.path.rstrip("/")
            redirect = f"{path}{querystring}"
        elif request.path == f"/{request.registry.route_prefix}":
            # Case for /v0 -> /v0/
            redirect = f"/{request.registry.route_prefix}/{querystring}"
        if redirect:
            resp = HTTPTemporaryRedirect(redirect)
            cache_seconds = int(request.registry.settings["trailing_slash_redirect_ttl_seconds"])
            if cache_seconds >= 0:
                resp.cache_expires(cache_seconds)
            return reapply_cors(request, resp)
    if response.content_type != "application/json":
        response = http_error(httpexceptions.HTTPNotFound(), errno=errno, message=error_msg)
    return reapply_cors(request, response)