Nextjs throws error hostname is not configured but i have wild card
Answered
AM posted this in #help-forum
AMOP
Hello i have following config in next.config.mjs:
but it fails to load image from here:
why is throwing this error aren't this config able to support this hostname?
images: {
dangerouslyAllowSVG: true,
remotePatterns: [{ protocol: 'https', hostname: '**' }, { protocol: 'http', hostname: '**' }]
},but it fails to load image from here:
https://raw.githubusercontent.com/0xbarbs/showcase/master/.gitshowcase/images/0.pngwhy is throwing this error aren't this config able to support this hostname?
44 Replies
AMOP
full error:
Error: Invalid src prop (https://raw.githubusercontent.com/0xbarbs/showcase/master/.gitshowcase/images/0.png) on `next/image`, hostname "raw.githubusercontent.com" is not configured under images in your `next.config.js`
See more info: https://nextjs.org/docs/messages/next-image-unconfigured-hostsomehow wildcard is catching
raw.githubusercontent.com?AMOP
cc @Ray ðŸ™
AMOP
P.S.: I've also tried enabling it
{ protocol: 'https', hostname: 'raw.githubusercontent.com' } but error continues to persistbecause the url contain a
.Answer
AMOP
this one here
.gitshowcase?yeah
AMOP
damn
how to by pass it any ideas
use img instead
there was an issue about it on github I think
AMOP
ahaa
just
i have a feed of items and i'm using Image, how i can fallback to img if Image is not working?
like will be tricky to check if url constains
.because is a url it contains it
create a component for it
but if this Image fails to load how to plug <img />
if (url.includes(".") {
return <img src={url} />
}
return <Image src={url} />AMOP
yeah ok but i mean is a url, it always includes ('.')
😄
maybe
url.replace(".png", "").includes(".")AMOP
hm goota thing about it because you might have
www.host.ext
new URL(url).pathname.replace(".png", "").includes(".")AMOP
or this one:
tttps://cast-sense.vercel.app/api/image?image=N4IgLghg5iBcIBMCWA3EAaEAHATgeywGc5RCwBPAGwFMSQJKkoA7ASTGoFtj4Bja5hxwYQAIwi8A1lHwBXZgjghGzahBwBaGRGQCwACjB4ABDiYALMOmMBiAKIBGRwDEAnNZvPndgMJ2AQgCUI...hm thanks man i will check what URL returns but thanks 

AMOP
yeah i've check it but i also got very dynamic feed
need to check it more carefully ðŸ™
yeah but you gotta do it until the issue got fixed
check the github issue on vercel and create a new one if there is none related to this
I remember there was one
AMOP
once again, thanks man, you are the boss 🔥
np😀
@Ray this is fixed in next@canary
AMOP
aww thank you so much man, any idea when they plan to release it
i assume we are talking about 14.2.0 version
@AM aww thank you so much man, any idea when they plan to release it
no idea, look for #60488 in release
Northern Rough-winged Swallow
how did you resolve dis issue cuz i have the same one my url has many . , ? etc