Skip to content

Instantly share code, notes, and snippets.

@Tam Tam/craft-ngrok.php
Created Jun 27, 2017

Embed
What would you like to do?
How to get ngrok working with Craft CMS during development
<?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,
),
],
// ...
);
@Bcdo

This comment has been minimized.

Copy link

commented Feb 23, 2019

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.