Disable SSR for some pages #1429
Replies: 4 comments 7 replies
-
This worked for me, thanks! |
Beta Was this translation helpful? Give feedback.
-
Here is, I think, a better alternative : Create a new HTTP Gateway where you want (e.g app folder): namespace App\Inertia;
use Illuminate\Support\Str;
use Inertia\Ssr\HttpGateway;
use \Inertia\Ssr\Response;
class InertiaHttpGateway extends HttpGateway
{
/**
* Dispatch the Inertia page to the Server Side Rendering engine.
*
* @param array $page
* @return Response|null
*/
public function dispatch(array $page): ?Response
{
if (isset($page['url']) && Str::is('/dashboard*', $page['url'])) {
return null;
}
return parent::dispatch($page);
}
} Last step, register the binding to your custom HTTP Gateway in your AppServiceProvider: use App\Inertia\InertiaHttpGateway;
use Inertia\Ssr\HttpGateway;
class AppServiceProvider extends ServiceProvider
{
public $bindings = [
HttpGateway::class => InertiaHttpGateway::class,
];
} Hope this helps. |
Beta Was this translation helpful? Give feedback.
-
My recommendation is to use the if (Request::is('nova/*')) {
Config::set('inertia.ssr.enabled', false);
} |
Beta Was this translation helpful? Give feedback.
-
These solutions cause the page to log errors
I assume due to |
Beta Was this translation helpful? Give feedback.
-
I realized that there is not documentation or anything for disabling SSR for some routes.
I have solved this with a workaround for now.
Add this before
@inertiaHead
in the blade layout fileapp.blade.php
:If someone has a better alternative, please share!
Beta Was this translation helpful? Give feedback.
All reactions