skip to Main Content
location @laravelapi {
        rewrite /api/(.*)?$ /api/index.php?$is_args$args last;
}

When we try access to api/routeexample, laravel gets only routeexample part, and throws 404 error. How we can send full url including ‘api’ part?

2

Answers


  1. Chosen as BEST ANSWER

    So I'm just added

    include "api.php";
    

    into my routes/web.php as hotfix, but i will search for better solution


  2. I m adding an example of how we define route for API request:

    In routes/api.php

    Route::group(['prefix' => 'v1'], function () {
    Route::post('api_request', [AppHttpControllersYourController::class, 'targeted_function_name'])->name('api_request');
    

    });

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search