Running 2 Server Then Cannot Access Resource When Cors Already Set

Multi tool use
Multi tool use


Running 2 Server Then Cannot Access Resource When Cors Already Set



I use 2 server in 1 PC and service already running



Server 1 :

- Rest Full with Java Spring Boot

- IP localhost:8098

- Source like this (sorry not full code)


@CrossOrigin(origins = {"http://10.100.0.207","http://localhost"}) @RequestMapping(value = "/getfiles", method = RequestMethod.GET, produces = "application/json")
public Map<String, ArrayList<String>> getFiles() {
return fullContent;
}



Server 2 :

- Using web service xampp

- file name testangular.html

- IP localhost

- Source like this (sorry not full code)




  • {{x}}

app.controller('getFiles', function($scope, $http) {
$http.get("http://localhost:8098/getfiles").then(function (response){
$scope.getdata = response.data;
});
});



A both service running success in my local PC with http://localhost/testangular.html because i set Cors in java


@CrossOrigin(origins = {"http://10.100.0.207","http://localhost"})



Now i connected 2 PC with same Wifi and running from different PC with http://10.100.0.207/testangular.html i cannot get data from server 1 (RestFull) but when i running http://10.100.0.207/testangular.html in PC server i got all data



10.100.0.207 is my local ip wifi where 2 service installed



can someone explain why i cannot get data from server 1




1 Answer
1



Looking to your configuration you are missing the port in origins (origins = {"http://10.100.0.207:8098","http://localhost:8098"})) you can also just do all domains what is the default @CrossOrigin


origins


@CrossOrigin





sorry, sir i edit question i cannot get data from server 1(my java restfull) in server 2(call api) is success
– Fakhryan Albar
Jul 3 at 8:43





Did you hard coded $http.get("http://localhost:8098/getfiles") because this will only work on 1 pc the one that has http://localhost:8098/getfiles running
– Victor Perez
Jul 3 at 8:53


$http.get("http://localhost:8098/getfiles")


http://localhost:8098/getfiles





yes sir, i understand know thx, i change to 10.100.0.207:8098
– Fakhryan Albar
Jul 3 at 9:31






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

KIzp1l,6D,sL CUwty Rpu0K4ns4c2s4B0OvTj X
MX,VMzdTcpq9A,AJASWfXFOPsbRa1q1,3YIqc5sKekQdt 3NJO9 zrN3qicXwMk,ibA4KUqLl,gX5q wycJPHi1DNP9u8Q tE,49Z8loc

Popular posts from this blog

PHP contact form sending but not receiving emails

Do graphics cards have individual ID by which single devices can be distinguished?

Create weekly swift ios local notifications