Closed CosmicodeStudio closed 10 months ago
This is because Nova is essentially a different app, they have different build files etc. So instead of using Inertia to navigate to it you'd just use a normal anchor tag
The error is in the SSR daemon, running with php artisan inertia:start-ssr
. It occurs every time someone goes to the backoffice, I don't have any link from the website to Laravel Nova.
i'm having the same problem
The error is in the SSR daemon, running with
php artisan inertia:start-ssr
. It occurs every time someone goes to the backoffice, I don't have any link from the website to Laravel Nova.
Temporarily I'm checking if the page exists, and if not, I added an empty page.
let page = pages[`./Pages/${name}.jsx`];
if (!page) {
page = pages[`./Pages/Empty.jsx`];
}
We have solved it like this, just add a reference to this middleware right before HandleInertiaRequests::class
in nova.php
's middleware.web
section
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
/**
* The purpose of this middleware is to disable Inertia SSR for Nova, while keeping it enabled for the rest of the app
* The middleware needs to be registered in config/nova.php for Nova web routes
*/
class DisableInertiaSSRForNovaMiddleware
{
public function handle(Request $request, Closure $next)
{
config()->set('inertia.ssr.enabled', false);
return $next($request);
}
}
Hey folks! Yup this is a known issue with Nova. Since Nova is built with Inertia.js, when you're running the Inertia SSR server and hit a Nova endpoint, the SSR server tries to render that page but fails, since Nova isn't setup for SSR (and it doesn't make any sense for it to be).
The way I have handled this in a project of mine that uses Inertia.js and Nova is by adding the following snippet to my AppServerProvider
:
if (Request::is('nova/*')) {
Config::set('inertia.ssr.enabled', false);
}
This will disable SSR just for the Nova endpoints and prevent this issue.
I've been meaning to ask the fine Nova folks to add this to Nova directly, and this is a good reminder to do that. (Pinging @jessarcher for help on this 😄 )
Going to close this issue in the meantime since it's not something that we're even able to fix in this library.
Hope that helps! 🤙
I'm using SSR for a SPA with React and Laravel for backend. I'm using a default layout for all pages that I added in createInertiaApp in app.jsx and ssr.jsx. I'm using Laravel Nova for content management, the problem is SSR is giving me an error everytime I enter in Laravel Nova. I know Laravel Nova uses Inertia as well, but it shouldn't conflict with my project. The error that is giving me:
This line is where I have
Have this happened to someone? I don't know why Laravel Nova is using my createInertiaApp.