Skip to content

Commit

Permalink
chore(http): skip throttling for local env (#851)
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewKostka authored Aug 1, 2024
1 parent 5e27dd3 commit ec2ddac
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 211 deletions.
3 changes: 1 addition & 2 deletions app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class Kernel extends HttpKernel
protected $middlewareAliases = [
// Came with Laravel
'auth' => \App\Http\Middleware\Authenticate::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,

'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
Expand All @@ -45,7 +44,7 @@ class Kernel extends HttpKernel

'backend.auth' => \App\Http\Middleware\BackendAuth::class,
'throttle.signup' => \App\Http\Middleware\ThrottleSignup::class,
//'throttle' => App\Http\Middleware\ThrottleRequests::class,
'throttle' => \App\Http\Middleware\Throttle::class,
//'auth' => App\Http\Middleware\Authenticate::class,
];

Expand Down
28 changes: 28 additions & 0 deletions app/Http/Middleware/Throttle.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Routing\Middleware\ThrottleRequests;

class Throttle extends ThrottleRequests {

/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param int|string $maxAttempts
* @param float|int $decayMinutes
* @param string $prefix
* @return \Symfony\Component\HttpFoundation\Response
*
* @throws \Illuminate\Http\Exceptions\ThrottleRequestsException
*/
public function handle($request, Closure $next, $maxAttempts = 60, $decayMinutes = 1, $prefix = '') {
if (config('app.env') === 'local') {
return $next($request);
}
return parent::handle($request, $next, $maxAttempts, $decayMinutes, $prefix);
}
}
209 changes: 0 additions & 209 deletions app/Http/Middleware/ThrottleRequests.php

This file was deleted.

0 comments on commit ec2ddac

Please sign in to comment.