Using @nuxt/image, can i place domains list in a custom module?
in nuxt.config.ts:
can i populate this list of domains in a module? Because i want to apply some base64 encoding to domain names in order to hide them
2 Replies
Hi @AlexanderKim. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
The knowledge sources do not explicitly mention whether you can programmatically populate the
- You can use a local module to mutate Nuxt config, including the
image.domains
list from a custom module, nor do they describe encoding or obfuscating domain names for this purpose.
However, Nuxt does support local modules that can modify the Nuxt configuration at build time. The modules/ directory documentation shows that you can define local modules that run before the Nuxt app is built, and these modules can access and mutate the Nuxt config object. This means, in principle, you could write a module that decodes or generates the domains
list and injects it into the image
config before Nuxt starts.
But, there is no documentation or example in the provided sources that demonstrates this specifically for the @nuxt/image
module or for encoding/obfuscating domains. Also, keep in mind that the domains
list is used to whitelist external image sources for optimization, and obfuscating them (e.g., with base64) may break the intended functionality, since the actual domain names must match the real image URLs.
In summary:- You can use a local module to mutate Nuxt config, including the
image.domains
array, but this is not shown specifically in the documentation for @nuxt/image
.
- There is no information about encoding or hiding domain names in the domains
list.
- The domains must be real, whitelisted hostnames for image optimization to work as intended.
If you need to hide domain names, be aware this may interfere with how Nuxt Image matches and optimizes remote images, as the module expects actual hostnames in the domains
array modules directory image configuration.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@349254666296492032> Kapa.ai is still learning and improving, please let me know how I did by reacting below.