Replies: 1 comment
-
Apparently, the error that VSCode return is not accurate. I am still able to run the app and by passing in a fake CSRF token, I am able to trigger the error. However, I have a question. Why does
always display 500 Even
will display 0 instead of 1. And yet this block of codes will return the correct response?
On further tests, this piece of code will return 419:
I am new to Laravel and Inertia so this behavior perplexes me. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I ran into this error "Undefined method 'status'" on this line: "if ($response->status() === 419)"
I am following the instructions listed on this page for handling CSRF: https://inertiajs.com/csrf-protection
use Throwable;
use Inertia\Inertia;
/**
Prepare exception for rendering.
@param \Throwable $e
@return \Throwable
*/
public function render($request, Throwable $e)
{
$response = parent::render($request, $e);
if ($response->status() === 419) {
return back()->with([
'message' => 'The page expired, please try again.',
]);
}
return $response;
}
Extend the render() method in your App\Exceptions\Handler.php.
What am I missing?
P.S. Running on the latest Laravel and Inertia.
Beta Was this translation helpful? Give feedback.
All reactions