1

My website occasionally loses images due to the image url being set to http://default/sites/files/XXXX.jpg. The "default" baseurl is the issue and as i understand drupal 8 has no way of setting this manually.

As this seems to happen sporadically i am assuming it is related to a cron job running under baseurl of "default" and then the page being saved to the cache.

Anyone have any ideas how to diagnose or possible causes? i was thinking something like SimpleSiteMap could be affecting this.

thanks

UPDATE After some testing it seems likely that its a cron job accessing the pages and the image urls being cached incorrectly.

The cron jobs run under base url of 'http://default' so the chain of events seems to be: cron starts clears caches a cron job attempts to render the page causing the img urls to be cache incorrecly

If i then clear the cache again and navigate to the pages the urls are re-written and cached correctly now.

2
  • 1
    How are you running the cron job? If you are using Drush cron you need the --uri parameter. – CG Monroe Oct 3 '17 at 19:44
  • 1
    Ah I forgot/didnt know about that parameter. I am not actually sure how the CRON on our production site is being called but i am pretty sure that the uri parameter has not been set yet. I am expecting this to solve my issues, will update once this is confirmed. thanks CG Monroe! – penance Oct 4 '17 at 8:19
1

Have you tried setting

$settings['file_public_base_url'] = 'http://sitename.local/sites/default/files';

In sites/default/settings.php?

I do this for all of my sites both in dev and production and haven't had any issues.

I realise that you may have solved the issue, but just so you know you can set the base url for your files through that setting :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.