问题出在哪里
在Internet Explorer中访问IFrame中的站点时,我面临令牌不匹配问题。
到目前为止我尝试了什么
我搜索解决方案并找到此链接
下面是我在上面的链接中找到的代码
App::after(function ($request,$response){
if($request->is('external/*')){
// IE iframe cookie fix
$response->header('P3P',
'CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"');
}
});
问题是什么
在Laravel 5.2中,我应该在哪里写上面的代码?
您应该创建after中间件,并将此中间件添加到web
中间件中,假设您的路由使用web
组中间件。
示例中间件:
<?php
namespace AppHttpMiddleware;
use Closure;
class FixIeFrameMiddleware
{
public function handle($request, Closure $next)
{
$response = $next($request);
if($request->is('external/*')){
// IE iframe cookie fix
$response->header('P3P',
'CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"');
}
return $response;
}
}
现在,在web
组的$middlewareGroups
属性中的app/Http/Kernel.php
中,您应该添加新的数组元素:
AppHttpMiddlewareFixIeFrameMiddleware::class,