simplemap
simplemap copied to clipboard
Running Feedme to populate data in simplemap throws error
Description
I am using Feedme plugin to automatically pull data to entry through atlas API. I have address ready. It throws error when map try to generate lat/lng. error is: Please configure UrlManager::hostInfo correctly as you are running a console application. - UrlManager.php: 648
I debug the error and found that I am on console application when queue is running from feedme. that makes this code invalid.
(ether/simplemap/src/services/GeoService.php) Line Number: 774.

Error from queue is, it needs instance of \yii\web\Request and it gets instance of \craft\console\Request.
Steps to reproduce
- Install Feedme plugin.
- add any address JSON and pull throgh feedme. (make sure lat/lng are not set.)
- Run feed me to add that data to entry.
Solution
it works If I change this portion:
$data = (string) static::_client()->get($url, [
'headers' => [
'referer' => Craft::$app->urlManager->getHostInfo()
]
])->getBody();
to this:
$data = (string) static::_client()->get($url, [
'headers' => [
'referer' => Craft::getAlias('@web')
]
])->getBody();
Additional info
- Craft version: 3.7.37
- Maps version: 3.9.3
- PHP version: 7.4.20
- Database driver & version: MySQL 5.7.37
- Feedme version: 4.4.2
Does changing to: 'referer' => Craft::getAlias('@web') work for both feed-me operations and the front end or do you need to make the change just for doing the feed-me and then revert to have the front end working correctly ?
It works on both frontend and feed me (queues).
I would do something like this:
$data = (string) static::_client()->get($url, [
'headers' => [
'referer' => Craft::$app->getRequest()->getIsConsoleRequest() ? Craft::getAlias('@web') : Craft::$app->urlManager->getHostInfo()
]
])->getBody();
Thank you for the speedy reply!
@tombo118 Just changed above code a bit to be more accurate. Do we have any updates or ETA on when it can get sorted?
@mufi-siebird I opened a PR for this issue if you could +1 it for me I'd appreciate it.