我有一个 Laravel API 服务器,它只有一个网络路由(测试页面),其他一切都通过dingo/api
包控制,一切正常。
在config/api.php
我设置'prefix' => env('API_PREFIX', '/')
为它只是一个 API 服务器。
从那以后,我安装了 Laravel Nova 并在/nova
路由上不断收到 JSON 错误消息:No hint path defined for [nova]
.
我最终发现我需要将前缀更改为'prefix' => env('API_PREFIX', '/api')
. 现在 Nova 工作正常,但我的 API 路由被破坏了。
在 Postman 中,当我执行 GET /test
(prefix /
) 时,Nova 不起作用,当我执行/api/test/
(prefix /api
) 时,Nova 确实起作用,但我在 API 返回时收到错误:
{
"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": "->"
},
...
]
}
没有错误消息,我看不出有什么问题?另外,当我这样做时,php artisan api:routes
我会得到正确的路线:
+------+----------+-----------------+------+-----------------------------------------------+-----------+------------+----------+------------+
| Host | Method | URI | Name | Action | Protected | Version(s) | Scope(s) | Rate Limit |
+------+----------+-----------------+------+-----------------------------------------------+-----------+------------+----------+------------+
| | GET|HEAD | /something/test | | App\Http\Controllers\Auth\AuthController@test | No | v1 | | |
+------+----------+-----------------+------+-----------------------------------------------+-----------+------------+----------+------------+