<?php
header("Access-Control-Allow-Origin: *"); 
header("Access-Control-Allow-Headers: Content-Type, Authorization, X-Requested-With");
header("Access-Control-Allow-Methods: POST, GET, DELETE, OPTIONS, PUT");
header("Content-Type: application/json");

// Enable caching for GET requests (60 seconds)
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
    header("Cache-Control: public, max-age=60");
} else {
    header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
}

if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
    http_response_code(204); 
    exit();
}
// Database
$host = "localhost";
$user = "grcomnp_petiteuser"; 
$pass = "#U~{*B)X1TVEIsn*";
$db   = "grcomnp_petiteDB";

$conn = new mysqli($host, $user, $pass, $db);

if ($conn->connect_error) {
    http_response_code(500);
    echo json_encode(["error" => "Database Connection Failed"]);
    exit;
}
