Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ahmetbarut's avatar

How to i blocked remote request ?

Hello everyone, I am requesting a post from within the project in Laravel, but I do not want 3rd party users to pull data from here using Curl. How do I prevent this? Passing CSRF is not too hard, I tried.

0 likes
3 replies
Robstar's avatar

Couple of options:

  • validate the requesting host / ip
  • pass a key known only to yourself within the the rewquest header i.e. a bearer token
kea_rajab's avatar

Middleware is the answer to your problem from my perspective... protect your routes using middlewares like

Route::get('/route', [YourControlller::class, 'YourFunctionInYourController'])->name('YourRouteName')->middleware('YourMiddlewareName');

this will throttle your routes from unwanted requests

Snapey's avatar

Implement authorisation using Sanctum or Passport and send bearer token with the request

Please or to participate in this conversation.