File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change 22
33namespace App \Providers ;
44
5+ use Illuminate \Cache \RateLimiting \Limit ;
6+ use Illuminate \Http \Request ;
7+ use Illuminate \Support \Facades \RateLimiter ;
58use Illuminate \Support \ServiceProvider ;
69
710class AppServiceProvider extends ServiceProvider
811{
12+ /**
13+ * The path to your application's "home" route.
14+ *
15+ * Typically, users are redirected here after authentication.
16+ *
17+ * @var string
18+ */
19+ public const HOME = '/home ' ;
20+
921 /**
1022 * Register any application services.
1123 */
@@ -20,5 +32,14 @@ public function register(): void
2032 public function boot (): void
2133 {
2234 //
35+
36+ $ this ->bootRoute ();
37+ }
38+
39+ public function bootRoute (): void
40+ {
41+ RateLimiter::for ('api ' , function (Request $ request ) {
42+ return Limit::perMinute (60 )->by ($ request ->user ()?->id ?: $ request ->ip ());
43+ });
2344 }
2445}
Original file line number Diff line number Diff line change 11<?php
22
3+ use App \Providers \AppServiceProvider ;
34use Illuminate \Foundation \Application ;
45use Illuminate \Foundation \Configuration \Exceptions ;
56use Illuminate \Foundation \Configuration \Middleware ;
1516 )
1617 ->withMiddleware (function (Middleware $ middleware ) {
1718 $ middleware ->redirectGuestsTo (fn () => route ('login ' ));
18- $ middleware ->redirectUsersTo (RouteServiceProvider ::HOME );
19+ $ middleware ->redirectUsersTo (AppServiceProvider ::HOME );
1920
2021 $ middleware ->web (\App \Http \Middleware \DisableFloc::class);
2122
You can’t perform that action at this time.
0 commit comments