I am working on project with microservices, and i have some issues. I have a ReactJS frontend, and a ASP.NET API, and i am working on docker/kubernetes environment. I try to fetch data on my front from API like this :
const https = require("https");
const agent = new https.Agent({
mode: "cors",
method: 'GET',
rejectUnauthorized: false
})
return fetch(hostApi1 +'/api/Weather/Index', { agent })
hostapi1=https://10.0.96.227:5001 The Frontend have a public ip, and the api a private ip.
But the console return this error :
FetchWeather.tsx:130 GET https://10.0.96.227:5001/api/Weather/Index net::ERR_CONNECTION_TIMED_OUT
But when i try this from the front container :
curl -k https://10.0.96.227:5001/api/Weather/Index
I obtain a good response with my data.
So there some specifics to add in my request for fetch data on API with private IP ? (when i add a public ip for my api it works, but this this not the aim)
Thanks for any help.
Your ReactJS frontend is running in user's browser. So you need to connect to backend using external IP. You cannot use private cluster ip from outside the cluster.