July 30, 2020 - 1 min read
When using ngrok
to tunnel connections to Laravel, Laravel keeps using the internal hostname (i.e. laravel.localhost
or similar) instead of the ngrok URL to build routes, even though you’ve added the ngrok URL to .env
in APP_URL
. You can overcome this by telling Laravel to force the given root URL by adding this to your app\Providers\AppServiceProvider.php
;
public function boot() {
URL::forceRootUrl(Config::get('app.url'));
}
Written by Peter Jaap Blaakmeer @PeterJaap