information overload

by sebastian de deyne

Don't skip `else` with octane

22 Jun 2026

I came across a subtle Octane but last week. We needed to disable Inertia’s history encryption in some places in the app. By default, it’s enabled everywhere. So we added a route check to the middleware to turn it off.

class HandleInertiaRequests
{
    public function handle(Request $request, Closure $next)
    {
        if ($request->is('admin/*')) {
            Inertia::encryptHistory(false);
        }
        
        // …
    }
}

The problem is, if you’re running Octane and make a request to an admin/* route, history encryption will be disabled, and there’s nothing to re-enable it for the next request.

The fix is to make sure both sides of the statement are executed.

class HandleInertiaRequests
{
    public function handle(Request $request, Closure $next)
    {
        if ($request->is('admin/*')) {
            Inertia::encryptHistory(false);
        } else {
            Inertia::encryptHistory(true);
        }
        
        // …
    }
}

Or more succinct:

class HandleInertiaRequests
{
    public function handle(Request $request, Closure $next)
    {
        Inertia::encryptHistory(! $request->is('admin/*'));
 
        // …
    }
}

Information Overload newsletter

I occasionally send out a dispatch with personal stories, things I'm working on, and interesting links I come across.

Only for occasional updates. No tracking.