Search code examples
laravellaravel-5.1laravelcollective

Laravel 5.1 with LaravelCollective Forms actions are loading as HTTP instead of HTTPS


I'm using the LaravelCollective HTML module to add forms to some views. The problem is that the actions in the forms are being generated at HTTP urls instead of HTTPS. Is there a way to make it just use whatever protocol the page loads as without having to explicitly spell out each absolute URL in the form call? Here's an example of the form tag I'm using in a view:

{!! Form::model(Auth::user(),['route','step1.post']) !!}

Solution

  • The route helper function will generate the correct url (including http/https protocol) according to route names as defined in routes.php.

    Try for instance

    Route::post('/user', ['https', 'UserController@post'])->name('step1.post');
    

    in routes.php, and then

    {!! Form::model(Auth::user(), ['url' => route('step1.post')]) !!}
    

    in your view.