server icon indicating copy to clipboard operation
server copied to clipboard

SSR specific page

Open ayophanz opened this issue 3 years ago • 2 comments

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

ayophanz avatar Feb 12 '22 06:02 ayophanz

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);
    }
}

timacdonald avatar Aug 09 '22 00:08 timacdonald

Thanks

ayophanz avatar Aug 09 '22 05:08 ayophanz