-
Notifications
You must be signed in to change notification settings - Fork 11.7k
Closed
Description
Laravel Version
12.x
PHP Version
8.4
Database Driver & Version
No response
Description
Laravel comes with a built-in health check endpoint on /up, which is defined in the bootstrap/app.php file as an argument of the withRouting method. In specific circumstances, this endpoint is stripped out, in particular, when routes are defined utilizing the "using" parameter as an alternative to "web".
Current Behaviour
When running php artisan route:list in a fresh Laravel app, you get something similar to the following
GET|HEAD / ......................................
GET|HEAD storage/{path} ........... storage.local
GET|HEAD up .....................................When defining routes with the "using" parameter, the health check endpoint is removed from the routes, as we can observe by executing the route list again.
GET|HEAD / ......................................
GET|HEAD storage/{path} ........... storage.localExpected Behaviour
The health check endpoint is perverse regardless of the way routes are defined, either utilizing web or using as an argument for withRouting.
Steps To Reproduce
- Create a fresh Laravel installation (e.g., laravel new my-app).
- Open the bootstrap/app.php file.
- Locate the default
Application::configure(...)->withRouting(...)block:
return Application::configure(basePath: dirname(__DIR__))
->withRouting(
web: __DIR__.'/../routes/web.php',
commands: __DIR__.'/../routes/console.php',
health: '/up',
)
->withMiddleware(...)
->withExceptions(...)
->create();- Run
php artisan route:listand confirm the presence of the /up health check route. - Modify the withRouting configuration by replacing the web file with an inline route using the using parameter:
->withRouting(
using: function (Application $app) {
Route::get('/', function () {
return view('welcome');
});
},
// web: __DIR__.'/../routes/web.php', <-- remove or comment out
commands: __DIR__.'/../routes/console.php',
health: '/up',
)- Run
php artisan route:listagain.
Metadata
Metadata
Assignees
Labels
No labels