Skip to content

Built-in health up/ route view does not respect the APP_BASE_PATH environment variable #54310

Closed
@wojo1206

Description

@wojo1206

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

  1. Modify Application::configure to enable the health path.
  2. Generate symlink to your app path to simulate alternative path.
  3. Set the symlink to your ENV variable: export APP_BASE_PATH=[YOUR_SYMLINK_PATH]
  4. run php artisan optimize
  5. Inspect the cached file (~/bootstrap/cache/routes-v7.php), and you’ll see the path for up/ does not begin with APP_BASE_PATH.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions