0

I am trying to get the base url of the drupal 8 website in a queue process but I am getting http://default as the base url. What am I missing here?

 public function testUrl() { global $base_url; var_dump($base_url); $host = \Drupal::request()->getSchemeAndHttpHost(); var_dump($host); // output - http://default $host2 = \Drupal::request()->getHost(); var_dump($host2); // output - default $uri = \Drupal::request()->getUri(); var_dump($uri); // output - http://default $url = \Drupal\Core\Url::fromUserInput('/', ['absolute' => TRUE])->toString(); var_dump($url); // output - http://default $url_options = [ 'absolute' => TRUE, 'language' => \Drupal::languageManager()->getCurrentLanguage(), ]; $site_url = \Drupal\Core\Url::fromRoute('<front>', [], $url_options)->toString(); var_dump($site_url); // output - http://default var_dump($_SERVER['SERVER_NAME']); // output - NULL die; } 

1 Answer 1

2

The process running the queue worker will be setting that default host. For example, drush cron

You may need to set the public host name with the drush request, via uri or use a drush alias.

drush --uri=http://example.com cron 

More info https://docs.drush.org/en/8.x/usage/

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.