Auto-deploy: 2026-05-17 01:43:14
This commit is contained in:
1
server/.env.example
Normal file
1
server/.env.example
Normal file
@@ -0,0 +1 @@
|
||||
GEMINI_API_KEY="your_api_key_here"
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user