51 lines
1.4 KiB
PHP
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']);
|
|
}
|
|
}
|
|
}
|