Reputation: 6007
I have this codes in my routes/api.php
file:
Route::group(['middleware' => 'auth:api'], function () {
Route::prefix('photoalbum')->group(function() {
Route::prefix('image')->group(function() {
Route::post('download/{albumId}/{size}/{filename}',
'PhotoalbumImageController@download');
// ...
});
});
});
Route::fallback('HomeContorller@index');
Now I try to open this URL:
http://myproject.test/api/photoalbum/image/download/1/xs/dog.jpg
...and I get the result from the HomeController@index
function. The other routes working fine.
UPDATE
The php artisan route:list
get the correct list of routes, contain this:
| | POST | api/photoalbum/image/download/{albumId}/{size}/{filename} | | App\Http\Controllers\PhotoalbumImageController@download | api,auth:api,auth |
Additionally: the requested file isn't exists. The controller should be process and serve it.
Why don't catch the request my defined Route and send it to the PhotoalbumImageController@download
function and how can I fix it?
Upvotes: 0
Views: 340
Reputation: 891
Please try this, and use name for routes it is useful, and remember if the call is GET, POST, PUT, etc.
Route::group(['middleware' => 'auth:api','prefix'=>'photoalbun/image'], function () {
Route::match(['post','get'],'/download/{albumId}/{size}/{filename}','PhotoalbumImageController@download')->name('api.photoalbun.image.download');
});
To see all route you can use
php artisan route:list
Upvotes: 0
Reputation: 225
Your defined route type is POST and you are trying to access that via GET.
changing your route to Route::get
solves your problem.
Upvotes: 2