First of all: Thank you to all previous posters, without you, I would have really been stuck on this.
I would just like to add some detail here, as I came across the same problem, that kirby()->cache('pages')->flush()
did not work in my code and it took me quite some time to figure it out, even after reading this post the above related post:
As mentioned in the other post, adding the url option does make kirby()->cache('pages')->flush()
work. But if you have a multi-environment setup, like bvdputte wrote above
and try to bootstrap from a CLI script, it throws an error.
As I did not understand how to achieve what bnomei and bvdputte wrote in the two posts above this one, I tried using env.php
to override the url in the config, as is stated in kirby docs here.
So, in short, my solution is (examples from kirby docs):
- Specifiy an allowlist of domains in the general
config.php
like so
return [
'url' => [
'https://example.com',
'https://staging.example.com',
'http://localhost'
]
];
- Override url in production and every environment you need
kirby()->cache('pages')->flush()
to work in fileenv.php
like so:
return [
'url' => 'https://example.com'
];