Conflict in routing between Laravel Nova and Dingo API

Barham

New Member
#1
I have a Laravel API server which only has one web route (test page), everything else is controlled via dingo/api package and all is working correctly.

In config/api.php I've set 'prefix' => env('API_PREFIX', '/') as it's only an API server.

I've since installed Laravel Nova and kept getting JSON errors message on the /nova route: No hint path defined for [nova].

I eventually figured out I need to change the prefix to 'prefix' => env('API_PREFIX', '/api'). Now Nova works correctly, but my API routes are broken.

In Postman when I do GET /test (prefix /) works, but Nova doesn't, and when I do /api/test/(prefix /api), Nova does work but I get an error on the API return:
Mã:
{
    "message": "",
    "exception": "Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException",
    "file": "/home/vagrant/Code/guest-api/vendor/laravel/framework/src/Illuminate/Routing/RouteCollection.php",
    "line": 179,
    "trace": [
        {
            "file": "/home/vagrant/Code/guest-api/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
            "line": 633,
            "function": "match",
            "class": "Illuminate\\Routing\\RouteCollection",
            "type": "->"
        },
        {
            "file": "/home/vagrant/Code/guest-api/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
            "line": 622,
            "function": "findRoute",
            "class": "Illuminate\\Routing\\Router",
            "type": "->"
        },
        ...
    ]
}
Without an error message, I can't see what is wrong? Also, when I do php artisan api:routes I get the correct route back:
Mã:
+------+----------+-----------------+------+-----------------------------------------------+-----------+------------+----------+------------+
| Host | Method   | URI             | Name | Action                                        | Protected | Version(s) | Scope(s) | Rate Limit |
+------+----------+-----------------+------+-----------------------------------------------+-----------+------------+----------+------------+
|      | GET|HEAD | /something/test |      | App\Http\Controllers\Auth\AuthController@test | No        | v1         |          |            |
+------+----------+-----------------+------+-----------------------------------------------+-----------+------------+----------+------------+
 

Admin

Administrator
Thành viên BQT
#2
Instead of adding the /api as a fallback parameter, you should add the prefix to your .env file like: API_PREFIX=api as described here
 
Top