Skip to content

Commit cea88ab

Browse files
authored
Merge pull request #60663 from nextcloud/R0Wi-patch-1
Add fallback for Codespace environment variables
2 parents 8d61504 + 6bf4cfe commit cea88ab

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

.devcontainer/codespace.config.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,19 @@
77
$codespaceName = getenv('CODESPACE_NAME');
88
$codespaceDomain = getenv('GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN');
99

10+
// When running under Apache, env vars from the shell profile are not inherited.
11+
// Fall back to the Codespaces shared environment file and the well-known domain.
12+
if (empty($codespaceName)) {
13+
$sharedEnvFile = '/workspaces/.codespaces/shared/environment-variables.json';
14+
if (is_readable($sharedEnvFile)) {
15+
$sharedEnv = json_decode(file_get_contents($sharedEnvFile), true) ?? [];
16+
$codespaceName = $sharedEnv['CODESPACE_NAME'] ?? '';
17+
}
18+
}
19+
if (!empty($codespaceName) && empty($codespaceDomain)) {
20+
$codespaceDomain = 'app.github.dev';
21+
}
22+
1023
$CONFIG = [
1124
'mail_from_address' => 'no-reply',
1225
'mail_smtpmode' => 'smtp',

0 commit comments

Comments
 (0)