Created
June 27, 2017 12:34
-
-
Save Tam/6df24d524657475422feb910aa5cf1aa to your computer and use it in GitHub Desktop.
How to get ngrok working with Craft CMS during development
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// When using: | |
// `ngrok http -host-header=example.dev 80` | |
$isNgrok = array_key_exists("HTTP_X_ORIGINAL_HOST", $_SERVER) && strpos($_SERVER["HTTP_X_ORIGINAL_HOST"], "ngrok"); | |
$host = 'http://' . $_SERVER[$isNgrok ? 'HTTP_X_ORIGINAL_HOST' : 'SERVER_NAME'] . '/'; | |
return array( | |
// ... | |
'.dev' => [ | |
'devMode' => true, | |
'siteUrl' => $host, | |
'environmentVariables' => array( | |
'baseUrl' => $host, | |
), | |
], | |
// ... | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have tried this so many times, but it just does not do it for me. The links created by the entry does not consider the ngrok.io, and tries to connect to the dev server directly. And the admin login page does not work properly, it does not respond to me pressing the login button. I can however type in manually the entry url with the ngrok.io, and it shows me the pages I want.
I use homestead, not sure if that can have anything to do with it?