Ad

Why Don't Catch The Requested File URI My Defined Route In Laravel 5.7?

- 1 answer

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}',
                  '[email protected]');
      // ...
    });
  });
});

Route::fallback('[email protected]');

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 [email protected] 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\[email protected]          | 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 [email protected] function and how can I fix it?

Ad

Answer

Your defined route type is POST and you are trying to access that via GET. changing your route to Route::get solves your problem.

Ad
source: stackoverflow.com
Ad