Closed amiranagram closed 4 years ago
I came to leave this exact issue. Thanks @classjunky
UPDATE:
Here's a quick fix:
Fortify::loginView(function (Request $request) {
return inertia('Auth/Login')->toResponse($request);
});
@markbiek
I have the same problem, any official solution?
@leo95batista The solution I provided above works just fine, you can see that on https://xp.amirrami.com.
Although I wish for a simpler solution, since I, like most Laravel developers like to keep it simple.
Feel free to pr, thanks.
Could you tell me how to exactly config Inertia in FortifyServiceProvider? This is how i have FortifyServiceProvider
This solution is causing
ErrorException strpos() expects parameter 1 to be string, object given
from \vendor\laravel\framework\src\Illuminate\View\ViewName.php:17
for me
Edit: Updating composer dependencies AND using double quotes on "Auth/Login" has fixed it
I wonder if this is what you're looking for... maybe this could help you or someone out there :)
Fortify::loginView(function () {
return Inertia::render('Auth/Login');
});
OR
Fortify::loginView(function () {
return route('login');
});
Given that route('login')
is declared as...
//routes/web.php
Route::get('login', [LoginController::class, 'create'])->name('login');
//Auth/LoginController.php
public function create(Request $request, Router $router)
{
return Inertia::render('Auth/Login');
}
Description:
I did some debugging, and basically when you return an Inertia response in a common controller
Illuminate\Routing\Router::toResponse()
receives Inertia\Response object where then it calls its owntoResponse()
to returnIlluminate\Http\Response
and all is good.But, using:
it fails to build the response because of the
SimpleViewResponse
and simply returns andInertia\Response
object instead of a string, hence the error above.Steps To Reproduce:
Configure Inertia, make a Vue component
resources/js/Pages/Auth/Login.vue
and inFortifyServiceProvider::boot()
paste: