How to create PHP Private API?

Viewed 13

I am a CS student and little new to REST API. Currently I am developing a simple API from PHP 8. It must be private API, where no one from outside of calling code (calling code is a VUE 3 app index.html page inside same domain) can access my API endpoint. I searched little bit and found that using Apache .htaccess like following can be used to protect my API.

order deny,allow
deny from all
allow from 127.0.0.1

Also, I came to know that using Basic Authentication can also be used.

My question is, are these methods effective when using a production-level API applications? Or are there any better approach to making a Private PHP Rest API?

0 Answers
Related