21 lines
740 B
PHP
21 lines
740 B
PHP
<?php
|
|
header('Content-Type: application/json');
|
|
header('Access-Control-Allow-Origin: *'); // Pastikan ini ada jika frontend dan backend beda domain/port
|
|
header('Access-Control-Allow-Methods: POST');
|
|
header('Access-Control-Allow-Headers: Content-Type'); // Tambahkan ini agar aman
|
|
|
|
require_once '../includes/auth.php';
|
|
|
|
// Pastikan hanya POST request, walaupun logout seringkali GET, tapi lebih aman POST
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
$auth = new Auth();
|
|
$result = $auth->logout();
|
|
echo json_encode($result);
|
|
} else {
|
|
// Jika ada yang mencoba akses langsung dengan GET, bisa kasih pesan error
|
|
echo json_encode([
|
|
'status' => 'error',
|
|
'message' => 'Method not allowed for logout'
|
|
]);
|
|
}
|
|
?>
|