check in RouteServiceProvider.. if using api.php route file, laravel already prepends it with api/ so you dont have to in api.php
GET parameters from API routes not getting detected
I use deployer to deploy my laravel application from a repository. Locally the application functions as intended, however, on the server there is unexpected behavior. I have a simple route in api.php (see below) that returns this error: Too few arguments to function App\Http\Controllers\ApiController::user(), 0 passed and exactly 1 expected.
api.php
Route::get('user/{id}', 'ApiController@user');
ApiController.php
public function user($id)
{
return response()->json([
'test' => $id
]);
}
php artisan route:list
+--------+----------+---------------------+-----------------------------+-----------------------------------------------------+------------+
| Domain | Method | URI | Name | Action | Middleware |
+--------+----------+---------------------+-----------------------------+-----------------------------------------------------+------------+
| | GET|HEAD | api/api/user/{id} | generated::vyXpDYUXPJPIHU1b | App\Http\Controllers\ApiController@user | api |
(I'm unsure why the URI is prefixed with "api/api/" rather than just "api/", it still renders on /api/user/)
Additionally, routes that return 404 errors locally (i.e. routes that don't exist) return error 500 on the server with the error: No routes found for "/routename/", which makes me wonder if this could mean that there is a problem with routing in general on the server?
Using laravel 7.0.0 and PHP 7.3.17
I've resolved this issue by transferring my files to a new laravel 7.6 project.
Please or to participate in this conversation.