diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 8d851577bc..fe4e218364 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -1,10 +1,22 @@ configureHttps(); + $this->configurePasswordValidation(); + $this->configureCommands(); + $this->configureModels(); + $this->configureDates(); + $this->configureRequestExceptions(); + $this->configureVite(); + } + + /** + * Configure HTTPS for production. + */ + private function configureHttps(): void + { + if (App::isProduction() && config('app.force_https')) { + URL::forceScheme('https'); + } + } + + /** + * Configure password validation for production. + */ + private function configurePasswordValidation(): void + { + if (App::isProduction()) { + Password::defaults(function () { + return Password::min(12) + ->mixedCase() + ->letters() + ->numbers() + ->symbols() + ->uncompromised(); + }); + } + } + + /** + * Configure commands for production. + */ + private function configureCommands(): void + { + if (App::isProduction()) { + DB::prohibitDestructiveCommands(); + } + } + + /** + * Configure models. + */ + private function configureModels(): void + { + if (! App::isProduction()) { + Model::preventLazyLoading(); + } + Model::preventAccessingMissingAttributes(); + Model::unguard(); + + Relation::enforceMorphMap([ + // Add you polymorphic relations here. For example: + // 'application' => \App\Models\Application::class, + ]); + } + + /** + * Configure dates. + */ + private function configureDates(): void + { + Date::use(CarbonImmutable::class); + } + + /** + * Configure request exceptions. + */ + private function configureRequestExceptions(): void + { + if (! App::isProduction()) { + RequestException::dontTruncate(); + } + } + + /** + * Configure Vite for better performance. + */ + private function configureVite(): void + { + Vite::useAggressivePrefetching(); } } diff --git a/config/app.php b/config/app.php index 324b513a27..9e0e9faa94 100644 --- a/config/app.php +++ b/config/app.php @@ -1,7 +1,8 @@ env('APP_NAME', 'Laravel'), + 'name' => env('APP_NAME', 'Coolify'), /* |-------------------------------------------------------------------------- @@ -54,6 +55,30 @@ return [ 'url' => env('APP_URL', 'http://localhost'), + /* + |-------------------------------------------------------------------------- + | Application Port + |-------------------------------------------------------------------------- + | + | This value determines the port your application is running on. It can be + | used to change what port the application is running on. + | + */ + + 'port' => env('APP_PORT', null), + + /* + |-------------------------------------------------------------------------- + | Force HTTPS + |-------------------------------------------------------------------------- + | + | This option can be used to force your application to use HTTPS instead + | of HTTP, providing an additional layer of security for your application. + | + */ + + 'force_https' => env('APP_FORCE_HTTPS', false), + /* |-------------------------------------------------------------------------- | Application Timezone @@ -101,7 +126,7 @@ return [ 'previous_keys' => [ ...array_filter( - explode(',', env('APP_PREVIOUS_KEYS', '')) + explode(',', env('APP_PREVIOUS_KEYS', '')), ), ], @@ -122,5 +147,4 @@ return [ 'driver' => env('APP_MAINTENANCE_DRIVER', 'file'), 'store' => env('APP_MAINTENANCE_STORE', 'database'), ], - ];