fix: Add fallback for Codespace environment variables

Signed-off-by: Robin Windey <ro.windey@gmail.com>
This commit is contained in:
Robin Windey 2026-05-22 17:51:41 +02:00 committed by GitHub
parent cbc8033a44
commit 6bf4cfe049
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -7,6 +7,19 @@
$codespaceName = getenv('CODESPACE_NAME');
$codespaceDomain = getenv('GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN');
// When running under Apache, env vars from the shell profile are not inherited.
// Fall back to the Codespaces shared environment file and the well-known domain.
if (empty($codespaceName)) {
$sharedEnvFile = '/workspaces/.codespaces/shared/environment-variables.json';
if (is_readable($sharedEnvFile)) {
$sharedEnv = json_decode(file_get_contents($sharedEnvFile), true) ?? [];
$codespaceName = $sharedEnv['CODESPACE_NAME'] ?? '';
}
}
if (!empty($codespaceName) && empty($codespaceDomain)) {
$codespaceDomain = 'app.github.dev';
}
$CONFIG = [
'mail_from_address' => 'no-reply',
'mail_smtpmode' => 'smtp',