-
Notifications
You must be signed in to change notification settings - Fork 288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Images not loading on Netlify #1330
Comments
cc: @pi0 |
Hi @scottyzen I attempted to reproduce with following
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
devtools: { enabled: true },
modules: ["@nuxt/image"],
image: {
// force ipx, as otherwise it would default to using Netlify Image CDN (which probably is better to use, but issue is about ipx)
provider: "ipx",
domains: ["secure.woonuxt.com"],
},
}); and <template>
<div>
<NuxtImg src="https://secure.woonuxt.com/wp-content/uploads/2021/10/T_1_front-500x500.jpg" />
</div>
</template> however I was unable reproduce the problem, as things seems to work (with double
I've used freshly created project, so maybe it's matter of upgrading your dependencies - it seems like with everything being Regardless of above, I would suggest using Netlify Image CDN (over ipx) when deploying to Netlify (it should be default unless you are forcing ipx) as it's better suited to run image transformation than running ipx/sharp on general purpose lambdas |
Hi @pieh Thanks for looking into it. I ended up having to go with Netlify's image CDN, for the time being anyway. But even with that I still had to update the [images]
remote_images = ["https://secure.woonuxt.com/.*"] Passing the domain into the NuxtImg settings isn't enough to get them working. 🤔 |
Currently want to deploy to netlify as well. The used images are located in the Deploying on netlify the Changing the deploy settings build command to |
Hmmm, this should be automatic since #1287 (with my reproduction attempt I didn't need to do that manually, I just declared domains in |
Hi, @pieh, I just had read of the Netlify docs about the remote-path and it say's that you only need to double-escape regex in the nuxt.options.nitro = defu(nuxt.options.nitro, {
netlify: {
images: {
// remote_images: moduleOptions.domains.map(domain => `https?:\\/\\/${domain.replaceAll('.', '\\.')}\\/.*`)
remote_images: moduleOptions.domains.map((domain) => `https://${domain.replace(/(^\w+:|^)\/\//, '')}/.*`),
}
} |
@scottyzen can you share your nuxt config (part related to images configuration)? I used same one as in #1330 (comment) with just |
Hi @pieh , Sure, I've tried almost every combination of settings. Here's what I have now: image: {
provider: 'netlify',
domains: ['secure.woonuxt.com'],
}, As soon as I comment out the following in my netlify.toml file it breaks: # [images]
# remote_images = ["https://secure.woonuxt.com/.*"] So at the moment, for me anyway. I need to set the remote_images in the .toml file for the images to work. Once that's set either provider ( netlify or ipx ) will work. |
Is scottyzen/woonuxt#157 where you are doing that exploration? If it is then I noticed that if I use |
https://github.com/unjs/nitro/blob/346a49508b58b747f164ff7aca062ba74174fcbe/src/presets/netlify-v2.ts#L29-L40 this seems to need to be replicated (with at least some adjustment as directories point to different things) to It seems to me that this config setting for images should be similarly common for each variant of preset in same way as |
@pieh Yeah, I'm using |
With Netlify Edge Preset the images are still ending in a 404. Works: nitro: {
preset: 'netlify',
}, Breaks: nitro: {
preset: 'netlify-edge',
}, Could this issue be connected with the problem here? |
I ran into the same issue and investigated a little bit further. Nitro's Netlify edge functions are run for every single route, and nitro's endpoint is set for
the generated Nitro edge function would not capture the request and Netlify would end serving it. This is not a problem with the |
I'm not sure if this is an issue with this module or just Netlify itself. There is also a thread here about it Netlify CDN Image 404 - Nuxt. Would love to hear if anyone else is having this issue.
I've redeployed to vercel and the images are working fine there. So I'm guessing it's an issue with Netlify. See both sites below:
Both sites are using IPX for image transformation. The only difference I can see is after the IPX options in the image url, there is a single slash on Vercel and a double slash on Netlify. By removing one of the slashes on Netlify, the image works fine. There seem to be a redirect somewhere that is not happening. Woundering if this is something that can be fix from this module or if it's something that Netlify needs to fix. Any help would be appreciated.
Example of the image url:
The text was updated successfully, but these errors were encountered: