Reputation: 11498
I'm using Laravel 4.2 and everything looks fine. But I have a problem with the SSL when I use Form::open()
Function. It always using HTTP without SSL even when the site is using SSL.
I saw this question: Laravel: HTTPS in Form::open() But there's 2 problems with that: I need to do it manually for each form. and when I program on my Wamp Server, I have HTTP so it won't work on my localhost.
So my question is, How can I auto secure the form if the site is using SSL?
Upvotes: 9
Views: 912
Reputation: 6016
You can create a route group with the https
option, and insert all of your routes inside that group.
Example:
Route::group(array('https'), function(){
// All routes goes here
});
Then your forms should be https
.
Another solution may be just:
URL::forceSchema("https");
Upvotes: 4
Reputation: 4576
You can use Request::secure()
to check if the request is over HTTPS and use the return value in the URL helper like this:
Form::open(array('url' => URL::to('/', array(), Request::secure())))
This way you form should automatically use HTTP or HTTPS depending if the current request is using HTTPS or not.
Upvotes: 4