From 6bf4cfe04994ab6798c2071fe63bffacde09c65c Mon Sep 17 00:00:00 2001 From: Robin Windey Date: Fri, 22 May 2026 17:51:41 +0200 Subject: [PATCH] fix: Add fallback for Codespace environment variables Signed-off-by: Robin Windey --- .devcontainer/codespace.config.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.devcontainer/codespace.config.php b/.devcontainer/codespace.config.php index 95d4e021a9e..0fa45c16b3e 100644 --- a/.devcontainer/codespace.config.php +++ b/.devcontainer/codespace.config.php @@ -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',