files – how to prevent my and composer.json from being access publicly?

I have a file which contains some written texts and a composer.json
the problem is when i typed along with the url of my site, it gets downloaded.
if i type composer.json appended to my url, it gets displayed. is there a way to prevent these two files from being downloaded or viewed by public ?