Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I want to hide json file from public access. How do I do that?

I got a website, and the javascript file is loading a json file(using getJson) into options of one select element based on previous select option.

But in the mean time, public can access that json file directly.

I only want server can access this file and loads corresponding options in theselect element. But I don't want public can access that json file directly(avoid them downloading and such..)

How do I do this? Via htaccess? or sth else? I tried 'FILES' rule in htaccess but the server cannot access the json file either.

like image 942
JustinHo Avatar asked Feb 16 '23 01:02

JustinHo


1 Answers

Javascript running at client side, so your visitor can get any resource used by javascript. If you want to hide anything, you need to replace your javascript code by server-side generation.

like image 70
Andrej Bestuzhev Avatar answered Apr 02 '23 07:04

Andrej Bestuzhev