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 2
2
3
3
namespace App \Providers ;
4
4
5
+ use Illuminate \Cache \RateLimiting \Limit ;
6
+ use Illuminate \Http \Request ;
7
+ use Illuminate \Support \Facades \RateLimiter ;
5
8
use Illuminate \Support \ServiceProvider ;
6
9
7
10
class AppServiceProvider extends ServiceProvider
8
11
{
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
+
9
21
/**
10
22
* Register any application services.
11
23
*/
@@ -20,5 +32,14 @@ public function register(): void
20
32
public function boot (): void
21
33
{
22
34
//
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
+ });
23
44
}
24
45
}
Original file line number Diff line number Diff line change 1
1
<?php
2
2
3
+ use App \Providers \AppServiceProvider ;
3
4
use Illuminate \Foundation \Application ;
4
5
use Illuminate \Foundation \Configuration \Exceptions ;
5
6
use Illuminate \Foundation \Configuration \Middleware ;
15
16
)
16
17
->withMiddleware (function (Middleware $ middleware ) {
17
18
$ middleware ->redirectGuestsTo (fn () => route ('login ' ));
18
- $ middleware ->redirectUsersTo (RouteServiceProvider ::HOME );
19
+ $ middleware ->redirectUsersTo (AppServiceProvider ::HOME );
19
20
20
21
$ middleware ->web (\App \Http \Middleware \DisableFloc::class);
21
22
You can’t perform that action at this time.
0 commit comments