I am trying to make a rails-api backend and react frontend website with docker-compose. But i couldn't send get request to rails-api backend with axios with my hostname (stated in docker-compose). I can access backend through localhost but that will be a problem (i assume) when i deploy the multi-container app to aws elastic beanstalk.
I am trying to access values like this:
const value = await axios.get('http://website:3000/api/v1/examples');
This is in my docker-compose.yml:
version: '2'
services:
website:
depends_on:
- 'postgres'
- 'redis'
build: .
ports:
- '3000:3000'
volumes:
- '.:/app'
env_file:
- '.env'
frontend:
build:
context: ./../atwo-react-2
dockerfile: Dockerfile.dev
ports:
- '3001:3001'
volumes:
- ./../atwo-react-2:/app
depends_on:
- website
I get this error instead
GET http://website:3000/api/v1/examples net::ERR_NAME_NOT_RESOLVED
in google console
Thank you in advance. Any help is most welcomed.