1

These setting up a new laravel8 project with jetStream InertiaJs, but when I start the application I get the following error:

enter image description here

Apparently it is a route error and the blogs show the solution to edit the RouteServiceProvider.php file and define the following variable:

protected $namespace = 'App\\Http\\Controllers';
$this->routes(function () {
            Route::prefix('api')
                ->middleware('api')
                ->namespace($this->namespace)
                ->group(base_path('routes/api.php'));

            Route::middleware('web')
                ->namespace($this->namespace)
                ->group(base_path('routes/web.php'));
        });

The web file paths are as follows:

Route::get('/', function () {
    return Inertia::render('Welcome', [
        'canLogin' => Route::has('login'),
        'canRegister' => Route::has('register'),
        'laravelVersion' => Application::VERSION,
        'phpVersion' => PHP_VERSION,
    ]);
});

Route::middleware(['auth:sanctum', 'verified'])->get('/dashboard', function () {
    return Inertia::render('Dashboard');
})->name('dashboard');

but the error remains, please someone can tell me a solution or that I should review to find a solution

3 Answers 3

3

Follow instructions here: https://inertiajs.com/server-side-setup

composer require inertiajs/inertia-laravel
php artisan inertia:middleware

Then the class should be found. Noticed the class couldn't resolve in the IDE, so assumed it wasn't installed by default out of the box.

Sign up to request clarification or add additional context in comments.

Comments

1

You may need to use Inertia\Inertia; at top of the PHP file before using it.

Comments

1

Based on the error, you may missed out a backward slash before App. Put it as below in your web.php file: \App\Http\Middleware\HandleInertiaRequests::class

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.