47 lines
No EOL
1.3 KiB
PHP
47 lines
No EOL
1.3 KiB
PHP
<?php
|
|
header('Content-Type: application/json');
|
|
header('Access-Control-Allow-Origin: *');
|
|
header('Access-Control-Allow-Methods: GET, POST, OPTIONS');
|
|
header('Access-Control-Allow-Headers: Content-Type, Authorization');
|
|
|
|
// Handle preflight requests
|
|
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
|
|
exit(0);
|
|
}
|
|
|
|
// Load environment variables from .env file
|
|
function loadEnv($path) {
|
|
if (!file_exists($path)) {
|
|
throw new Exception('.env file not found');
|
|
}
|
|
|
|
$lines = file($path, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
|
$env = [];
|
|
|
|
foreach ($lines as $line) {
|
|
if (strpos($line, '#') === 0) continue; // Skip comments
|
|
|
|
list($key, $value) = explode('=', $line, 2);
|
|
$env[trim($key)] = trim($value);
|
|
}
|
|
|
|
return $env;
|
|
}
|
|
|
|
try {
|
|
$env = loadEnv(__DIR__ . '/.env');
|
|
|
|
// Return client-side configuration (no secrets)
|
|
$config = [
|
|
'azure_client_id' => $env['AZURE_CLIENT_ID'] ?? '',
|
|
'azure_tenant_id' => $env['AZURE_TENANT_ID'] ?? '',
|
|
'redirect_uri' => 'http://localhost:3000/runway-video/public/'
|
|
];
|
|
|
|
echo json_encode($config);
|
|
|
|
} catch (Exception $e) {
|
|
http_response_code(500);
|
|
echo json_encode(['error' => 'Configuration error: ' . $e->getMessage()]);
|
|
}
|
|
?>
|