Created
April 14, 2015 14:38
-
-
Save uzegonemad/f30375bd4feebd42e719 to your computer and use it in GitHub Desktop.
Laravel 5 Middleware - Strip X-Requested-For Header
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php namespace App\Http\Middleware; | |
use Closure; | |
class StripHeaders { | |
/** | |
* Strip X-Requested-With from the request because we're handling | |
* all json output and don't want interference from Laravel. | |
* | |
* @param \Illuminate\Http\Request $request | |
* @param \Closure $next | |
* @return mixed | |
*/ | |
public function handle($request, Closure $next) | |
{ | |
// Remove from ServerBag / ParameterBag | |
$request->server->remove('HTTP_X_REQUESTED_WITH'); | |
// Remove from HeaderBag | |
$request->headers->remove('x-requested-with'); | |
return $next($request); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment