Skip to content

Commit

Permalink
feat: Detect when we're running in Codespaces, and swap in the dynami…
Browse files Browse the repository at this point in the history
…c URL for the `PRIMARY_SITE_URL` env var automatically
  • Loading branch information
khalwat committed Feb 14, 2023
1 parent 6c27924 commit 7a6fda7
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions config/general.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@
use craft\config\GeneralConfig;
use craft\helpers\App;

// Rewrite the PRIMARY_SITE_URL env var if we're running in Codespaces
if (App::env('CODESPACES')) {
// putenv() only affects the OS's environment, so set it directly
$_ENV['PRIMARY_SITE_URL'] = $_SERVER['PRIMARY_SITE_URL'] = sprintf(
"https://%s-%s.preview.app.github.dev/",
App::env('CODESPACE_NAME'),
App::env('DEV_SERVER_PORT')
);
}

return GeneralConfig::create()
->runQueueAutomatically(false)
// Set the default week start day for date pickers (0 = Sunday, 1 = Monday, etc.)
Expand Down

0 comments on commit 7a6fda7

Please sign in to comment.