Open Galaxy-ht opened 1 year ago
@Galaxy-ht
Change perMinute
in app/Providers/RouteServiceProvider.php
. This affects all api
:
protected function configureRateLimiting()
{
RateLimiter::for('api', function (Request $request) {
return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
});
}
Especially for lsky-pro, change throttle:3
to meet your need. The middleware limits how many tokens you can create in 1 minute:
Route::group([
'prefix' => 'v1',
'middleware' => CheckIsEnableApi::class,
], function () {
Route::get('strategies', [StrategyController::class, 'index']);
Route::post('upload', [ImageController::class, 'upload']);
Route::post('tokens', [TokenController::class, 'store'])->middleware('throttle:3');
Route::group([
'middleware' => 'auth:sanctum',
], function () {
Route::get('images', [ImageController::class, 'images']);
Route::delete('images/{key}', [ImageController::class, 'destroy']);
Route::get('albums', [AlbumController::class, 'index']);
Route::delete('albums/{id}', [AlbumController::class, 'destroy']);
Route::delete('tokens', [TokenController::class, 'clear']);
Route::get('profile', [UserController::class, 'index']);
});
});
请问在哪里可以设置接口的请求配额,或者如何解决短时间多次调用api会返回429状态码的问题