Skip to content

Instantly share code, notes, and snippets.

@novasky-zz
Created October 4, 2016 12:09
Show Gist options
  • Save novasky-zz/694831b9ff1565e344d1a281b975fcf7 to your computer and use it in GitHub Desktop.
Save novasky-zz/694831b9ff1565e344d1a281b975fcf7 to your computer and use it in GitHub Desktop.
Laravel 5 TokenMismatchException
When I realized this was only happening in IE and Chrome, but not Firefox, it led me to the fix.
The app was using AddThis share buttons and the javascript was adding an iframe to the pages.
This issue is resolved by adding a P3P header to the VerifyCsrfToken Middleware. Hope this saves somebody the hours I lost.
<?php
public function handle($request, Closure $next)
{
$response = $next($request);
if (last(explode('\\',get_class($response))) != 'RedirectResponse') {
$response->header('P3P', 'CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"');
}
return $response;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment