Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Elliot_putt's avatar

Inertia set Response code

Hi All,

Quick question , i need to assertForbidden() on an Inertia redirect.

in blade I can do this:

  return response(view('errors.403', [
            "link" => $link ,
            'message' => $message,

        ]), 403);

What is the equivalent of Inertia?

I tried this but no luck thanks.

 return response(Inertia::render('Auth/403', [
            'link' => $link,
            'message' => $message,
        ]), 403);
Symfony\Component\HttpFoundation\Response::setContent(): Argument #1 ($content) must be of type ?string, Inertia\Response given, called in /home/vagrant/Code/BookingSystem/vendor/laravel/framework/src/Illuminate/Http/Response.php on line 72
0 likes
3 replies
Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

Can you try

return Inertia::render('Auth/403', [
            'link' => $link,
            'message' => $message,
        ])->toResponse($request)->setStatusCode(403);
2 likes

Please or to participate in this conversation.