I have built a front-end Vue.js application, running on a docker container under kubernetes environment. the backend is also in the same kubernetes cluster (I am using Minikube for the project). When running it gets error net::ERR_NAME_NOT_RESOLVED
when connecting to back-end containers:
while inside the container, there is no problem connect to the back-end using curl:
$ kubectl exec -it deployment/hpl-browser-deployment -- sh
/ # curl http://hpl-manager-service:2354
{
"message": "Manager status",
"state": "IDLE"
}
I used axios
for the api service:
import axios from 'axios';
export default class APIService {
API_URL = '';
constructor(apiAddress) {
this.API_URL = apiAddress;
}
async get() {
console.log('ApiService: get()');
try {
const response = await axios.get(this.API_URL);
console.log(`ApiService: get result: ${response.data}`);
return response.data;
} catch (error) {
console.error(error);
return error;
}
}
async postPlainText(data) {
console.log(`ApiService: post() - data: ${data}`);
try {
const response = await axios.post(this.API_URL,
data,
{
headers: {
'Content-Type': 'text/plain',
Accept: '*/*',
},
});
console.log(`ApiService: post result: ${response.data}`);
return response.data;
} catch (error) {
console.error(error);
return error;
}
}
}
The application has no problem running on development environment, when I port-forward the back-end service, and connect to http://localhost:2354
.
I would like to know what may cause this problem?
所有评论(0)