Auto-deploy: 2026-05-17 01:43:14

This commit is contained in:
Hamza-Ayed
2026-05-17 01:43:14 +03:00
parent d547decc60
commit 26e0135104
5 changed files with 20 additions and 18 deletions

1
server/.env.example Normal file
View File

@@ -0,0 +1 @@
GEMINI_API_KEY="your_api_key_here"

View File

@@ -2,6 +2,7 @@
"name": "hamza/cv-generator",
"description": "Dynamic ATS-Optimized CV Generator",
"require": {
"dompdf/dompdf": "^3.0"
"dompdf/dompdf": "^3.0",
"vlucas/phpdotenv": "^5.6"
}
}

View File

@@ -22,16 +22,25 @@ if (!file_exists($autoloadPath)) {
require_once $autoloadPath;
use Dompdf\Dompdf;
use Dompdf\Options;
use Dotenv\Dotenv;
// Load .env if it exists
if (file_exists(__DIR__ . '/.env')) {
$dotenv = Dotenv::createImmutable(__DIR__);
$dotenv->load();
}
$rawData = file_get_contents('php://input');
$data = json_decode($rawData, true);
$action = $data['action'] ?? 'generateText';
$apiKey = $data['apiKey'] ?? '';
// Prioritize API key from .env over frontend payload
$apiKey = $_ENV['GEMINI_API_KEY'] ?? getenv('GEMINI_API_KEY') ?: ($data['apiKey'] ?? '');
if (empty($apiKey)) {
http_response_code(400);
echo json_encode(["error" => "Missing apiKey"]);
echo json_encode(["error" => "Missing apiKey. Please set GEMINI_API_KEY in .env or pass it in request."]);
exit;
}