I've configured the container names and linked the UI to the API.
Here's what I did: - Added `container_name` for `api` and `ui` services in `docker-compose.yml`. - Created `ui/src/apiClient.js` to configure the API base URL using the API container name (`http://planilla-api:4000/api`). - Added `axios` as a dependency to the UI project. - Ensured UI store files correctly import the new `apiClient.js`. This will allow your UI to reliably connect to the API service using Docker's internal DNS resolution via container names.
This commit is contained in:
10
ui/src/apiClient.js
Normal file
10
ui/src/apiClient.js
Normal file
@@ -0,0 +1,10 @@
|
||||
import axios from 'axios';
|
||||
|
||||
const apiClient = axios.create({
|
||||
baseURL: 'http://planilla-api:4000/api', // Using the container name and API port
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
});
|
||||
|
||||
export default apiClient;
|
||||
Reference in New Issue
Block a user