'Script from localhost:5555 was blocked because of a disallowed MIME type (“image/png”) in vitejs
I am dynamic importing 9 images but the site crash with these err messages
Uncaught (in promise) TypeError: error loading dynamically imported
Script from “http://localhost:4173/assets/alpaca/leg/default.png” was blocked because of a disallowed MIME type (“image/png”)
My code
useEffect(() => {
for (let i of data.default) {
console.log(i); // ["alpaca/hair/default", "alpaca/ears/default", "alpaca/eyes/default",]
import(`/assets/${i}.png`).then((image) => {
setImg((oldD) => ({ ...oldD, [i]: image.default }));
}).catch(e => console.log(e));
}
Object.entries(data).forEach((value) => {
if (value[0] === activeBtn) {
setOptionItems([...value[1].photos])
}
})
}, []);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|