Hi I have a problem with the api, when I move the script to the aapanel vps, my api doesn't work it shows 401,
"POST /api/pelanggan/login HTTP/2.0" 401 - "-" "okhttp/4.7.2"
code :
` function login_post()
{
if (!isset($_SERVER['PHP_AUTH_USER'])) {
header("WWW-Authenticate: Basic realm=\"Private Area\"");
header("HTTP/1.0 401 Unauthorized");
return false;
}
$data = file_get_contents("php://input");
$decoded_data = json_decode($data);
$reg_id = array(
'token' => $decoded_data->token
);
$condition = array(
'password' => sha1($decoded_data->password),
'no_telepon' => $decoded_data->no_telepon,
//'token' => $decoded_data->token
);`
But when I comment
` function login_post()
{
// if (!isset($_SERVER['PHP_AUTH_USER'])) {
// header("WWW-Authenticate: Basic realm=\"Private Area\"");
// header("HTTP/1.0 401 Unauthorized");
// return false;
// }
$data = file_get_contents("php://input");
$decoded_data = json_decode($data);
$reg_id = array(
'token' => $decoded_data->token
);
$condition = array(
'password' => sha1($decoded_data->password),
'no_telepon' => $decoded_data->no_telepon,
//'token' => $decoded_data->token
);`
The api is running normally, where is the error, what should I put in the php extension?