2

I built a pos application in Laravel and hosted it on a shared hosting server. on the live server when I try to send ajax request multiple times to add products from the right side pane(by clicking image one after one) it starts responding 403 forbidden after some request.

enter image description here

Any help, what I can do to prevent this, and what is the cause?

royallife
  • 98
  • 7
  • Compare the last successful request request with the first failed one. Check if the `Set-Cookie` value is set in both and the session cookie has the same value. – apokryfos Dec 04 '21 at 13:43
  • Suggestion: Don't use shared hosting server for live server. It has many restrictions – sumit sharma Dec 08 '21 at 08:25

1 Answers1

1

The reason behind the 403 is that laravel reject request if default request limit is reached out of limit. You can set the number of requests per min as per your project in app/Http/Kernel.php.

 'api' => [
            'throttle:150,1', // 150 requests per min
            \Illuminate\Routing\Middleware\SubstituteBindings::class,
        ],