Set authorization for laravel API call from reactjs
i have api like below,
this will display all posts in json format when we access this URL directly in browser or postman.
i am sharing this api to react js. right now there is no user authentication as this is open access website. but I want it to be only consumed by my application (reactjs), and prevent someone from the public access this api. Anyway to achieve this?
i have one approach like below,
create api key table in database and store str_random token. pass this this api key from reactjs axios header as authorization key
create one middleware where it will fetch authorization key header value and match with db key token and if it is same allow if not block.
is this fine?
Please or to participate in this conversation.