inertiajs / server

Inertia.js (SSR) Server
https://inertiajs.com/server-side-rendering
MIT License
41 stars 11 forks source link

SSR specific page #7

Open ayophanz opened 2 years ago

ayophanz commented 2 years ago

I have admin and public pages now I want to exclude all pages under admin folder and only SSR the pages under public folder.

timacdonald commented 2 years ago

You may create an application middleware that turns it back on or off for only the routes you would like.

For example, in Laravel we may do the following...

namespace App\Http\Middleware;

use Illuminate\Support\Facades\Config;

class EnableSsr
{
    protected $except = [
        'admin/*',
        'portal/*',
    ];

    public function handle($request, $next)
    {
        Config::set('inertia.ssr.enabled', ! $request->is($this->except));

        return $next($request);
    }
}
ayophanz commented 2 years ago

Thanks