1👍
I have solved it. Here is the correct one.
public function render($request, Throwable $e)
{
$response = parent::render($request, $e);
if (!app()->environment(['local', 'testing']) && in_array($response->status(), [500, 503, 404, 403])) {
return Inertia::render('Frontend/Error', ['status' => $response->status()])
->rootView('frontend.layouts.app');
} else if ($response->status() === 419) {
return back()->with([
'message' => 'The page has expired, please try again.',
]);
}
return $response;
}
0👍
You can’t simply return an array or json response , in Inertiajs you have to render view. If you want to user axios instead.
return Inertia::render('Users', [
'users' => $users
]);
Problem is here : return $response;
Render a view here. Some how your condition is not getting true.
-3👍
Check the Laravel logs: The first step is to check the Laravel logs to get more information about the error. By default, Laravel logs are stored in the storage/logs directory. Look for any error messages or stack traces that can help identify the cause of the issue.
Enable debug mode: If you’re not seeing detailed error messages in the logs, you can enable debug mode in your Laravel application. Open the .env file and set the APP_DEBUG variable to true. This will display detailed error messages directly in the browser, which can help identify the problem.
Check the Inertia::render method: Make sure that the Inertia::render method is being called correctly and that the specified view exists. Double-check the path and name of the Frontend/Error component to ensure it is correct. Also, verify that the component file exists in the expected location.
Verify the versions: Ensure that you have the correct versions of the @inertiajs/vue2 and @inertiajs/inertia-laravel packages installed. Check if there are any known compatibility issues or required updates for these packages. You can refer to the official documentation or GitHub repository of each package for more information.
Verify the response status codes: Check if the response status codes in your if conditions are accurate. Make sure that the conditions are correctly evaluating the desired status codes. If needed, you can temporarily remove the conditions or modify them to pinpoint the issue.
Check the application environment: Ensure that the application environment is correctly set in the .env file. Verify that the environment check (app()->environment([‘local’, ‘testing’])) is working as expected.