Search code examples
reactjslaravelinertiajs

Creating api request on Laravel with Inertia


I am currently using laravel 11.x with react Inertia. I want to make auth protected api routes for mobile app. Inertia does not give auth middleware for api. Its uses token authentication.

How to set up api middleware and routes in this situation.


Solution

  • In Laravel 11 you can create your own api-route(routes/api.php) by the following artisan command..

    php artisan install:api
    

    In Laravel 11 api.php and channels.php route files are no longer present by default.

    For more information see the official documents. Here are the links...

    https://laravel.com/docs/11.x/middleware

    Release note of Laravel 11 is given in the below links..

    https://laravel.com/docs/11.x/releases

    N:B :- You will get every aspect about how to create auth middlware and api route for building project using react-inertia.