Reputation: 199
$http.get('/someUrl').
success(function(data, status, headers, config) {
// this callback will be called asynchronously
// when the response is available
}).
In the above code, I want to hide the header information. Using the browser inspect method we can view the header information.
Upvotes: 0
Views: 1982
Reputation: 199
Javascript is client-side, which means it get's run from the client's machine. The end user will be able to inspect the code, and be able to see what it's attempting to do. Even if the code is obfuscated, it can still be converted or read and they will be able to see how it's making the request
Upvotes: 0
Reputation: 22911
It's not possible to hide requests. A couple of more additions (Not sure why this was downvoted, but I'll attempt to be more clear).
Javascript is client-side, which means it get's run from the client's machine. The end user will be able to inspect the code, and be able to see what it's attempting to do. Even if the code is obfuscated, it can still be converted or read and they will be able to see how it's making the request (Thus being able to interpolate what request headers would be sent.)
What if the client is using a custom browser? For example, one they wrote himself? You make a request to your server, and it's going to respond with your javascript/HTML. Then, their javascript parser is going to attempt to make the request, which they can then capture the request that is attempting to be made.
In chrome, web requests are logged for ease of use to the end developer. This is not something that can be disabled or turned off, because as I stated in my previous paragraph would only make it appear as if it's hidden, and wouldn't be effective at stopping someone who knows anything about the HTTP protocol.
And finally, even if this were possible, someone could monitor the traffic between the client and the server, and inspect network traffic to see what was sent and received (HTTP is a fully documented RFC protocol for interchanging web requests, and is essentially a giant string of headers and easily view-able.) In short, it's not possible.
Upvotes: 2