3

I'm using Laravel in an application that I would like to be HTTPS-only.

In one view that is shown on https://example.com/p I open a form like this:

{{ Form::open(['method' => "POST", "id" => "whatever"]) }}

Laravel parses it to this:

<form method="POST" action="http://example.com/p" accept-charset="UTF-8" id="whatever">

This looks good on the first sight, but remember, this is on an HTTPS page so I get a mixed-content warning when displaying the page.

But it gets even worse. I configured my server to redirect HTTP request to the according HTTPS resource. That means, my browser posts the form content to the server, which redirects it to the HTTPS-location. The browser then drops the POST-request and sends a regular GET-request to the server which results in exactly the same page the use has seen before.

Why does Laravel fill in the wrong protocol? How can I set the right one?

Johann Bauer
  • 2,488
  • 2
  • 26
  • 41
  • possible duplicate of [Laravel: HTTPS in Form::open()](http://stackoverflow.com/questions/26427443/laravel-https-in-formopen) – Dhiraj Feb 17 '15 at 01:30

1 Answers1

1

Define your routes with https option and call that route to form action. For Example"

Route

Route::group(array('https'), function(){
    // all of our routes
    //for your form acction
    Route::post('form', array('as' => 'form/action', 'uses' => 'ExampleController@postForm'));  
}

So the route under https group should be https, even route for form to.

Safoor Safdar
  • 5,516
  • 1
  • 28
  • 32