inertiajs / inertia-laravel

The Laravel adapter for Inertia.js.
https://inertiajs.com
MIT License
2.09k stars 235 forks source link

Add config option to ignore paths with SSR server #574

Open craigrileyuk opened 10 months ago

craigrileyuk commented 10 months ago

Probably a niche case, but in a Laravel project we have two completely separate builds. We have the frontend which uses SSR; then we have the backend admin panel which uses Inertia as well, but does not use SSR.

The problem is that the SSR server will try to respond to every single request (i.e. both the frontend and the backend).

As a quick fix, in inertia-laravel/src/Ssr/HttpGateway.php, in the dispatch function, I've done a check like so:

if (Str::startsWith($page['url'], '/admin')) {
     return null;
}

Would it be possible to add some way to ignore certain routes using the config?

MitichPavel commented 9 months ago

@craigrileyuk Maybe this a discussion can help you. can-inertias-ssr-feature-be-enabled-only-for-some-pages You can define two different layouts for admin panel and other pages. views/layouts/app.blade.php <-- this layout is basic and contains for example

@yield('head')

and you can add two additional layouts: admin.blade.php

// admin.blade.php
@extends('layout.app')

@php($__inertiaSsr = null)

and ssr.blade.php for inertia ssr pages.