Hide json data with React Native and Php

I use React Native and Php for my app. Php return json data from mysql. But if a user enter my fetch url in google, he can see my json data. How can i hide my data ?

$json = file_get_contents('php://input');

$result = mysqli_query($link, "SELECT * FROM news");

if(mysqli_num_rows($result)) {
    while($row[] = mysqli_fetch_assoc($result)) {
        $json = json_encode($row);
    }
}else {
    echo 'connection error';
}

Answer

Solution:

All things that can do browser, user able to do manually via browser's developer tools. So "hiding" data is a not correct solution.

My recommendations are:

  1. Allow only POST method, that will help you to avoid direct accesses via inserting URL into browser address bar (So, yes, you can "hide" data from direct access, but this is not solve global security problems).

  2. Add authentication. That is global security problem if any user can access to your Database. At least, add PHP or Apache Basic authentication. In other case add IP restrictions. That will allow to access your data only specific users. And that is much better and securely than "hiding" direct accesses

  3. Escape SQL prompts! That is important and help you avoid SQL injection problems.

Source