Skip to content

Instantly share code, notes, and snippets.

@unfulvio
Created November 29, 2024 02:17
Show Gist options
  • Save unfulvio/53242fa491aec74869ef369ea8fe5d10 to your computer and use it in GitHub Desktop.
Save unfulvio/53242fa491aec74869ef369ea8fe5d10 to your computer and use it in GitHub Desktop.
Setting up ngrok with Valet for WordPress use
# note this uses `ngrok` directly opposite `valet share`
# the `-host-header` param is essential and you can also configure that in `~/ngrok2/ngrok.yml` eventually
# in which case it should work also by simply calling `valet share` from the parked site root
ngrok http --host-header=rewrite https://your-valet-url.test
<?php
// insert these lines at the beginning of wp-config.php
if ( isset( $_SERVER['HTTP_X_FORWARDED_HOST'] ) ) {
$url = $_SERVER['HTTP_X_FORWARDED_HOST'];
} elseif ( ! empty( $_SERVER['HTTP_HOST'] ) ) {
$url = $_SERVER['HTTP_HOST'];
} else {
$url = 'https://your-valet-url.test'; // this fallback should not be necessary
}
define( 'WP_HOME', 'https://' . $url );
define( 'WP_SITEURL', WP_HOME );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment