Reputation:
I am using some java-script code in my JSP file but as I do not want client to see my code, I placed it in a codescript.js
file and included it through ajax like this
$.ajax({
cache: true,
dataType: "script",
url: "codescript.js"
});
But as I am accessing codescript.js file directly anyone can guess that it is stored in current directory. My file can be downloaded by just entering file name in url bar such as
pathtomysite\codescript.js
Is there any way to prevent clients to easily access my java-script files.
Upvotes: 0
Views: 153
Reputation: 18805
You can deny direct access by testing the Referer
header. This should basically deny direct access, but it can be spoofed.
RewriteCond "%{HTTP_REFERER}" "!www.example.com" [NC]
RewriteRule "\.(js)$" - [F]
Upvotes: 1