I have a function that generates image URLs. This function combines some relatively static global configuration with some dynamic data that changes on every invocation. I say "relatively static" because the configuration is loaded asynchronously during the application boot, but remains fixed after that.
export default async function imageUrl(imageId, { size = 'normal' }) {
if (imageId == null) return null
const constantsResponse = await fetch('/api/constants')
const imagesRoot = constantsResponse.json().imagesRoot