Hello, my name is Yoimar and I've been having a problem recently with my nuxt project. Look, I've externalized the source route of my images in a JavaScript file in utils folder. My images are located in ./assets/img/* , here everithing seems ok, but when I run the project images are not loading, the curious thing is if I enable the devtools the images load correctly. But I do not why... I hope the images I attach to this message are helpful.
PD: I'm not a native English speaker.
#Images only load with devtools enabled
7 messages · Page 1 of 1 (latest)
Another thing to add: devtools are not scanning the img folder in assets. Only the public folder.
If I write the image route directly in the src attribute the image loads correctly.
Images only load with devtools enabled
If you’re referencing images at runtime, I.e. via variable evaluation, you should consider putting them in public and using absolute path. Bundling and hashing assets this way won’t work unless the string is a static reference (I.e. not a variable)
Thanks.
Furthermore, if you want to add cache control heads etc, to static assets served from public, you can do so with some configuration https://nitro.unjs.io/config#publicassets