DEV Community 👩‍💻👨‍💻

Cover image for Laravel 6/7 secret route for maintenance bypass!
Laravel Article
Laravel Article

Posted on

Laravel 6/7 secret route for maintenance bypass!

From Laravel 8, you can bypass maintenance mode only for you with a secret route! It's a really nice and flexible feature to bypass maintenance mode only for you and your developer when the application in maintenance mode. We can use this kind of features in our existing laravel 6, laravel 7 projects with a lightweight laravel package called haruncpi/laravel-maintenance. Let's see how we can use it our project.

Install package

composer require haruncpi/laravel-maintenance
Enter fullscreen mode Exit fullscreen mode

Now replace the default maintenance middleware in app/Http/kernel.php

//\App\Http\Middleware\CheckForMaintenanceMode::class,
\Haruncpi\LaravelMaintenance\Middleware\MaintenanceMode::class,
Enter fullscreen mode Exit fullscreen mode

Installation finished!

  • Enable maintenance mode with secret route
php artisan down --secret="mysecretkey"
Enter fullscreen mode Exit fullscreen mode
  • Maintenance bypass
https://example.com/mysecretkey
Enter fullscreen mode Exit fullscreen mode

Here mysecretkey is a secret key which we defined earlier in artisan down command. Make sure you make it complex for better security.

After visiting the secret route, you will get the application live only in your side and the rest of the world gets it in maintenance mode.

Doc & GitHub repository: haruncpi/laravel-maintenance

Top comments (0)

Update Your DEV Experience Level:

Settings

Go to your customization settings to nudge your home feed to show content more relevant to your developer experience level. 🛠