<?php

namespace App\Providers;

use Illuminate\Support\Facades\URL;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    public function register(): void
    {
        //
    }

    public function boot(): void
    {
        // When Apache maps the site root to public/index.php, SCRIPT_NAME can still
        // contain "/public", which would make generated URLs include /public. Force
        // the configured APP_URL as the single source of truth for asset/route URLs.
        if (! $this->app->runningInConsole()) {
            $root = rtrim((string) config('app.url'), '/');
            if ($root !== '') {
                URL::forceRootUrl($root);
            }
        }
    }
}
