Laravel Version
11.39.1
PHP Version
8.2
Database Driver & Version
Not relevant
Description
When running php artisan optimize, I noticed the built-in health up/ route does not respect the APP_BASE_PATH environment variable. If APP_BASE_PATH differs from __DIR__, this causes the cached path to become invalid. After investigating, I traced the issue to the following file and lines:
src/Illuminate/Foundation/Configuration/ApplicationBuilder.php:
return response(View::file(__DIR__.'/../resources/health-up.blade.php', [
'exception' => $exception,
]), status: $exception ? 500 : 200);
It might be necessary to publish the view into the views directory first, though I couldn’t find documentation mentioning that. For now, I’ll just disable the up/ route in optimized deployments when APP_BASE_PATH is set.
Steps To Reproduce
- Modify
Application::configure to enable the health path.
- Generate symlink to your app path to simulate alternative path.
- Set the symlink to your ENV variable:
export APP_BASE_PATH=[YOUR_SYMLINK_PATH]
- run
php artisan optimize
- Inspect the cached file (
~/bootstrap/cache/routes-v7.php), and you’ll see the path for up/ does not begin with APP_BASE_PATH.
Laravel Version
11.39.1
PHP Version
8.2
Database Driver & Version
Not relevant
Description
When running
php artisan optimize, I noticed the built-in healthup/route does not respect theAPP_BASE_PATHenvironment variable. IfAPP_BASE_PATHdiffers from__DIR__, this causes the cached path to become invalid. After investigating, I traced the issue to the following file and lines:src/Illuminate/Foundation/Configuration/ApplicationBuilder.php:It might be necessary to publish the view into the views directory first, though I couldn’t find documentation mentioning that. For now, I’ll just disable the
up/route in optimized deployments whenAPP_BASE_PATHis set.Steps To Reproduce
Application::configureto enable the health path.export APP_BASE_PATH=[YOUR_SYMLINK_PATH]php artisan optimize~/bootstrap/cache/routes-v7.php), and you’ll see the path forup/does not begin withAPP_BASE_PATH.