inertia-laravel icon indicating copy to clipboard operation
inertia-laravel copied to clipboard

All Inertia requests must receive a valid Inertia response, however a plain JSON response was received.

Open yogeshgalav opened this issue 2 years ago • 3 comments

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

yogeshgalav avatar Mar 18 '22 07:03 yogeshgalav

Did you solve this? View the JSON response from the server. I suspect you are receiving an error.

scss-brad avatar Apr 06 '22 19:04 scss-brad

same any solve on this

alnutile avatar Jun 24 '22 11:06 alnutile

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

Tofandel avatar Sep 14 '22 08:09 Tofandel

The issue was solved by reinstalling project on production. Sorry for late comment.

yogeshgalav avatar Nov 16 '22 03:11 yogeshgalav

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

ChileNetwork avatar Jul 07 '24 02:07 ChileNetwork