我在Laravel 5.1中遇到Https请求问题
我创建了一个像这样的中间件:
<?php
namespace Subway\Http\Middleware;
use Closure;
use App;
use Redirect;
class UseSSL
{
public function handle($request, Closure $next)
{
if (!$request->secure() && env('APP_ENV') === 'local')
{
return redirect()->secure($request->getRequestUri());
}
return $next($request);
}
}
我的路线是这样的:
Route::group(['middleware' => 'use.ssl'], function () {
// All other routes here
});
我在kernel.php中注册了中间件
protected $routeMiddleware = [
'use.ssl' => \Subway\Http\Middleware\UseSSL::class,
];
尝试访问任何网址时,页面无法加载,终端返回此错误:
[Thu Nov 12 11:09:30 2015] ::1:50728 Invalid request (Unsupported SSL request)
这有什么问题?
答案 0 :(得分:0)
尝试跳过以下代码行:
public function boot()
{
if (!$this->app->isLocal()) {
$this->app['request']->server->set('HTTPS', true);
}
}
进入您的app/Providers/AppServiceProvider.php
文件