我最终完成了基于 Laravel 的 REST API。将 API 上传到共享网络托管后,我每次都会从 RouteCollection 收到 NotFoundHttpException 错误。
公用文件夹工作正常并且显示良好。但当我尝试将 API 与邮递员一起使用时,我收到以下错误:
{
"message": "",
"exception": "Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException",
"file": "/var/www/vhosts/cloud1.openhandwerk.de/httpdocs/API_oH/Connector/vendor/laravel/framework/src/Illuminate/Routing/RouteCollection.php",
"line": 179,
"trace": [
Run Code Online (Sandbox Code Playgroud)
现在,当我通过浏览器访问该页面时,只会收到 404 错误。
我的 api.php 文件
<?php
use Illuminate\Http\Request;
Route::prefix("v1")->group(function() {
Route::post('login', 'Api\v1\UserController@login');
Route::post('register', 'Api\v1\UserController@register');
Route::group(['middleware' => 'auth:api'], function(){
// Customers
Route::get("customers", 'Api\v1\CustomerController@index');
// Route::get("customer/{id}", "API/v1/CustomerController@show");
// Route::post("customer", "API/v1/CustomerController@store");
// Route::put("customers", "API/v1/CustomerController@store");
// Route::delete("customers", "API/v1/CustomerController@destroy");
});
});
Run Code Online (Sandbox Code Playgroud)