Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

dogma's avatar
Level 1

Skip pages for Inertia SSR

Hey none of the existing solutions:

Disable SSR for some pages

Can Inertia's SSR Feature Be Enabled Only for Some Pages?

helped me to fix the issue, that my ssr.js file is still beeing called on page refreshes and returns the following error:

TypeError: Cannot read properties of undefined (reading 'location')
    at setup /bootstrap/ssr/ssr.js:32:44)
    at /node_modules/@inertiajs/vue3/dist/index.esm.js:1:6122
    at async L (/node_modules/@inertiajs/vue3/dist/index.esm.js:1:6040)
    at async Server.<anonymous> (/node_modules/@inertiajs/vue3/node_modules/@inertiajs/core/dist/server.esm.js:1:527)

It's because I don't pass ziggy routes to some of my pages:

ssr.js

I also tried it via a Middleware:

use Closure;
use Illuminate\Http\Request;

class DisableSSRForCertainRoutes
{
    public function handle(Request $request, Closure $next)
    {
        if ($request->routeIs('admin.*')) {
            config(['inertia.ssr.enabled' => false]);
        }

        return $next($request);
    }
}

is there any way to exclude some pages from inertia?

0 likes
0 replies

Please or to participate in this conversation.