Cannot get or post data from API with Drupal app served with Docker Compose Cannot get or post data from API with Drupal app served with Docker Compose docker docker

Cannot get or post data from API with Drupal app served with Docker Compose


You should use \Drupal::httpClient(); instead of curl in drupal 8 (but curl should work too).

What's in your docker-compose.yml ?

Do you have something like this for your services ?

    services:      api:        extra_hosts:          - "my_api_hostname.local:0.0.0.0"        networks:          defaults:            aliases:              - my_api_hostname.local            front:        depends_on:          - api        extra_hosts:          - "my_front_hostname.local:0.0.0.0"        networks:          defaults:            aliases:              - my_front_hostname.local


First I want to say thanks to everyone who chipped in. In some way or another, you helped me get to where I am now, where it's working.

The solution? Completely format ubuntu, clean the disk and upgrade to ubuntu 20 from 16.