Hey everyone 👋
I’m running a new Laravel 12 app in production (deployed via Dokploy on a Hetzner VPS), and I’m facing a strange URL issue . Laravel sometimes generates links like:
https://http//localhost/register
Here’s what I’ve already checked:
✅ APP_URL=https://offline.ielts2go.com in .env
✅ URL::forceScheme('https') and URL::forceRootUrl(config('app.url')) in AppServiceProvider
✅ Cleared and re-cached configs: php artisan config:clear and config:cache
✅ HTTPS works fine on production
Here’s my current AppServiceProvider (relevant part):
if ($this->app->environment('production')) {
// Force HTTPS scheme
URL::forceScheme('https');
$this->app['request']->server->set('HTTPS', true);
// Ensure APP_URL is clean
$appUrl = rtrim(config('app.url'), '/');
// Force Laravel to use your configured domain as root
if (!empty($appUrl)) {
URL::forceRootUrl($appUrl);
}
}
Even though everything looks correct, Laravel still occasionally builds malformed URLs.
Has anyone run into this before, or know if URL::forceRootUrl() could conflict with something like the server headers or APP_URL parsing?
Thanks in advance 🙏