改进 限流器 只限制登录用户(因为未登录用户都没办法请求)
This commit is contained in:
parent
f40891d695
commit
99a48ec6c5
@ -59,10 +59,13 @@ public function boot()
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function configureRateLimiting()
|
protected function configureRateLimiting(): void
|
||||||
{
|
{
|
||||||
RateLimiter::for('api', function (Request $request) {
|
RateLimiter::for('api', function (Request $request) {
|
||||||
return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
|
// return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
|
||||||
|
|
||||||
|
// 只限制登录用户
|
||||||
|
return Limit::perMinute(60)->by($request->user()?->id);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user