inertia-laravel
inertia-laravel copied to clipboard
All Inertia requests must receive a valid Inertia response, however a plain JSON response was received.
I'm returning a valid inertia response from controller.
public function getStartedPage() { if(Auth::check()){ return redirect('/'); } return inertia('auth/get-started'); } And on local machine its working fine, but on production on every inertia link it's returning error in modal pop-up.
"All Inertia requests must receive a valid Inertia response, however a plain JSON response was received."
https://stackoverflow.com/questions/71522603/laravel-inertia-requesting-for-valid-response-on-production-server-however-works
Did you solve this? View the JSON response from the server. I suspect you are receiving an error.
same any solve on this
Or you are using a proxy and overwriting the content type or not proxying the X-Inertia headers, there is a lot of possible causes and without additional info it's impossible to know which
The issue was solved by reinstalling project on production. Sorry for late comment.
use Spatie\Permission\Exceptions\UnauthorizedException;
In your www/laravel-example/app/Exceptions/Handler.php class Handler extends ExceptionHandler { /**/ public function register(): void { $this->renderable(function (\Spatie\Permission\Exceptions\UnauthorizedException $e, $request) { Session::flash('flash_titulo', 'Unauthorized!!'); Session::flash('flash_variante', 'danger'); Session::flash('flash_mensaje', $e->getMessage()); return to_route('landing_page')->with(['error' => $e->getMessage()]); });