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

sm3rter's avatar

private API endpoint ?

Hey everyone, I've just set up an API in Laravel 11 and created my first endpoint:

// In routes/api.php Route::get('/', [ReportsController::class, 'index']);

I can access it without any issues via my localhost (e.g., http://127.0.0.1:8000/), and it returns the expected result. However, when I try accessing it using Postman, I still get the same result. I was expecting a 419 status code or something similar to prevent external access to my API.

Is there a way to make this endpoint private so it can't be accessed outside of my application?

0 likes
4 replies
talnluck's avatar

Are you running postman through their web url or installed postman in your local system?

azimidev's avatar

you can apply authentication middleware like auth:sanctum or auth:api. This will require the client to pass a valid token when making requests.

The laravel docs will tell you how to do each

Snapey's avatar

Your local machine WILL be private, and definitely not available externally at 127.0.0.1

However, you do need to address security

Please or to participate in this conversation.