HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux ip-172-26-0-120 6.17.0-1009-aws #9~24.04.2-Ubuntu SMP Fri Mar 6 23:50:29 UTC 2026 x86_64
User: ubuntu (1000)
PHP: 8.3.6
Disabled: NONE
Upload Files
File: /var/www/html/api.aianced.com/app/Providers/AppServiceProvider.php
<?php

namespace App\Providers;

use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     */
    public function register(): void
    {
        //
    }

    /**
     * Bootstrap any application services.
     */
    public function boot(): void
    {
        // 3 analyze requests per IP per 12 hours (720 minutes)
        RateLimiter::for('analyze', function (Request $request) {
            $ip = $request->header('CF-Connecting-IP') ?? $request->ip();
            return Limit::perMinutes(720, 3)
                ->by($ip)
                ->response(function () {
                    return response()->json([
                        'success' => false,
                        'message' => 'You have reached the limit of 3 idea analyses every 12 hours. Please try again later.',
                    ], 429);
                });
        });
    }
}