presseportale/app/Providers/AppServiceProvider.php
Kevin Adametz 405df0a122
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled
first commit
2025-10-20 17:53:02 +02:00

51 lines
1.4 KiB
PHP

<?php
namespace App\Providers;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*/
public function register(): void
{
//
}
/**
* Bootstrap any application services.
*/
public function boot(): void
{
// Force HTTPS when running behind a proxy (like Traefik)
if ($this->app->environment('local', 'production')) {
URL::forceScheme('https');
}
// Trust proxies for correct request detection
$this->app['request']->server->set('HTTPS', 'on');
// Set dynamic asset URL based on current domain/theme
// This is needed for Vite to use the correct asset subdomain
//config(['app.asset_url' => 'https://assets.businessportal24.test']);
//$this->setDynamicAssetUrl();
}
/**
* Set the asset URL dynamically based on the current theme
*/
protected function setDynamicAssetUrl(): void
{
try {
$assetUrl = \App\Helpers\ThemeHelper::getAssetUrl();
config(['app.asset_url' => $assetUrl]);
} catch (\Exception $e) {
// Fallback to default if theme detection fails
config(['app.asset_url' => 'https://assets.pr-copilot.test']);
}
}
}