Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

tayyabhussain's avatar

https routes for rest apis

hi ! i need to crate a rest api on https protocol, for that purpose i have created a filter Route::filter('forceHttps', function ($req) { if (!Request::secure()) { return Redirect::secure(Request::getRequestUri()); } }); and then applied to my route like this Route::group(array('prefix' => 'api/v1'), function () {

Route::group(['before' => 'https'], function () {

    Route::resource('top-players', 'Api_PlayerController@getTopFivePlayers');

});

}); when deploy this on server and hit it from postman server gives error in response ERROR : The requested URL /api/v1/top-players was not found on this server

0 likes
2 replies
tayyabhussain's avatar

I'v found the solution. there is nothing to change in laravel appliation for https routing. you just need to configure ssl certificate properly

pmall's avatar

You use Route::resource wrong. It should refers to a controller and not a controller action.

1 like

Please or to participate in this conversation.