Reputation: 9
I have issue with my app when I use Angular to consuming REST API request
The Web Service URLs store in the Angular service or controller js file so if I have Login web service to check usename and password like:
http://mylocal.com/api/service.json?api_user=Username&api_key=Password
The end users or developers can get this url and build a software to try finding the username and password, so how to hide the web services urls in angular js if that possible?
Example:
$scope.submit = function(request) {
$scope.contactUsSuccess = false;
$http.post('/_/contactUs' +
"?firstName=" + encodeURIComponent(request.first) +
"&lastName=" + encodeURIComponent(request.last) +
"&email=" + encodeURIComponent(request.email) +
"&phone=" + encodeURIComponent(request.phone) +
"&company=" + encodeURIComponent(request.company) +
"&message=" + encodeURIComponent(request.message)
) // Contact us
.success(function(reply){
console.log(reply);
$scope.contactUsSuccess = true;
$scope.contactUs = "";
})
.error(function(){
alert('There seemed to be a problem with your submission. Please refresh the page and try again.')
});
};
You can get the contact url web service and use it, so how can i solve this issue?
Upvotes: 0
Views: 2145
Reputation: 1423
First off this is really bad if you're doing this over HTTP and not HTTPS. Sending this over HTTP sends your credentials in text/plain for anyone to sniff and grab on the network.
I'm assuming they are not using specific firewall rules either.
Because of the REST endpoint you're dealing with, you could initiate the REST call in a few different ways:
Upvotes: 1