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

wkarim86's avatar

Laravel RESTful API with X-API-KEY header

I am new in Laravel and I want my Laravel 5.0 backend server to accept X-API-KEY with header for any all type of request with the above specific header. It should return error. Basically I want to secure my backend request. I don't want anyone to access it with out API KEY that I stored in my .env.

example: http://localhost/api/v1/getusers/1 headers: X-API-KEY="2acddkasjslfs"; //something like this. If X-API-KEY matches with my .env APP_KEY it should return response otherwise return error.

Please help it is urgent.

0 likes
2 replies

Please or to participate in this conversation.