Laravel app我正在尝试在 中的其他一些域中使用iframe。
我写了一个FrameMiddleware,其中我在标头中允许该域
public function handle(Request $request, Closure $next)
{
$response = $next($request);
$response->header('Content-Security-Policy', 'frame-ancestors http://localhost');
return $response;
}
Run Code Online (Sandbox Code Playgroud)
并通过使用上面的中间件 cors origin 错误被删除。
因为我Laravel app需要来自 iframe 的身份验证。它使用表单提交,而不是 API。然后它开始给出一个
419 error. VerifyCsrfToken我通过在中间件数组中添加登录路由$except来排除csrf错误来解决。
然后我检查登录请求给出 302network错误post
我测试了身份验证方法,经过身份验证的用户对象通过页面重定向返回Dashboard,然后302 error code显示。
而且,我已经开始same_site => null工作了config/session.php,但仍然没有工作。