Answer the question
In order to leave comments, you need to log in
How to allow http traffic and change all http requests to https in Laravel?
Hello! I have two problems. Uploaded my project to the server (apache). Connected cloudfare, connected ssl. The site is now on https. And then the errors started:
1) For example, there is a form, I specify in the action {{route('action')}}
, and this route transfers to http, and such an error pops up
Заблокирована загрузка смешанного активного содержимого «http://
, but if you specify a normal path in action, that is /action
, then the request will go through https, so how to fix it so that the named route goes through https? This only happens with roots when I specify their name in the path, like this: <form action="{{route('name_route')}}"></form>
or when I use an axios request and in the Url I specify {{route('name_route')}}
. That is, such roots use the http protocol, but you need https. Answer the question
In order to leave comments, you need to log in
In the file with routes, writeURL::forceScheme('https');
1. Create a global http to https proxy
<?php
namespace App\Http\Middleware;
use Closure;
class HttpsProtocol
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (!$request->secure()) {
return redirect()->secure($request->getRequestUri(), 301);
}
return $next($request);
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question