laravel Https请求“无效请求(不支持的ssl请求)”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33677304/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Https requests "invalid request (unsupported ssl request)"
提问by Aarón Gutiérrez
I'm having problems with Https requests in Laravel 5.1
我在 Laravel 5.1 中遇到 Https 请求的问题
I created a Middleware like this:
我创建了一个这样的中间件:
<?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);
}
}
and my routes are like this:
我的路线是这样的:
Route::group(['middleware' => 'use.ssl'], function () {
// All other routes here
});
I registered the middleware in kernel.php
我在 kernel.php 中注册了中间件
protected $routeMiddleware = [
'use.ssl' => \Subway\Http\Middleware\UseSSL::class,
];
When trying to get to any url, the page doesn't load and the terminal is returning this error:
尝试访问任何 url 时,页面不会加载并且终端返回此错误:
[Thu Nov 12 11:09:30 2015] ::1:50728 Invalid request (Unsupported SSL request)
What's the problem with this?
这有什么问题?
回答by Dmitry Kychyra
Try to past this lines of code:
尝试越过这行代码:
public function boot()
{
if (!$this->app->isLocal()) {
$this->app['request']->server->set('HTTPS', true);
}
}
into your app/Providers/AppServiceProvider.php
file
进入你的app/Providers/AppServiceProvider.php
文件