Skip to content

Instantly share code, notes, and snippets.

@Tam
Last active June 25, 2019 10:30
Show Gist options
  • Save Tam/ff990dca1178431439fca739b7d0a5d5 to your computer and use it in GitHub Desktop.
Save Tam/ff990dca1178431439fca739b7d0a5d5 to your computer and use it in GitHub Desktop.
Using ngrok with Craft CMS 3
ngrok http -region=eu -host-header=my-dev-domain.local 443
<?php
$isNgrok = array_key_exists('HTTP_X_ORIGINAL_HOST', $_SERVER) && strpos($_SERVER['HTTP_X_ORIGINAL_HOST'], 'ngrok');
$host = $isNgrok ? ('https://' . $_SERVER['HTTP_X_ORIGINAL_HOST'] . '/') : getenv('DEFAULT_SITE_URL');
return [
'*' => [
// ...
'siteUrl' => $host,
'baseCpUrl' => $host,
'aliases' => [
'web' => $host,
],
],
// ...
];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment